-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add Logs support to mdatagen #12571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How would you use it? And what for? |
In the context of RDBMS receivers, I would like to be able to update the receiver to support the exporting of SQL query and query plan text data to the Logs pipeline along with some attributes such as timestamp, db/schema, user, etc. While Logs scraping can be added to a Receiver, the support is inconsistent and having mdatagen support would help set a standard for how this kind of integration can be done. |
Pinging code owners for cmd/mdatagen: @dmitryax. See Adding Labels via Comments if you do not have permissions to add labels yourself. For example, comment '/label priority:p2 -needs-triaged' to set the priority and remove the needs-triaged label. |
While working on the SQL Server receiver, I encountered similar use cases. I believe there are several benefits, particularly for scraper-based receivers, from supporting logs in Automatic Generation of Scope Name and VersionCurrently, we manually attach the scope name and version when constructing plog. Although this approach works, many scope versions may become outdated over time. Template-Based DocumentationDocumentation can become inconsistent across different scraper-based receivers. Using templates can help maintain consistency and uniformity. Avoiding Field Type ConflictsThere might be multiple scrapers calling databases and sending different log records for various use cases (e.g., sample query and top query). Field types may unexpectedly differ among these log records, potentially causing issues for subsequent consumers. Having a defined schema will help avoid such conflicts. Implementation PlanI plan to add the following specification to the schema for supporting logs in the initial version:
We can consider adding configurations as well in the next iteration:
@bogdandrutu I'm willing to implement this if the team agrees with this proposal. cc @open-telemetry/collector-approvers |
I'm not against this approach. However, we are now introducing some framework for receivers emitting structured log records while most of the receivers wouldn't be able to follow it. So maybe we can start with some generic functionality like Automatic Generation of Scope Name and Version and Template-Based Documentation and apply it to all log receivers. Then we proceed with other features and clearly mark receivers emitting structured logs when some specific features are applied to them. I'm suggesting this approach because it'll bring consistent usage of the mdatagen in log receivers instead of having this applied only to a couple of receivers while others are not even mentioned in metadata.yaml. |
Is there a discussion on the "structured log event" or other documentation?
It sound similar to other internal work I have seen and I'd like to
understand it better, regardless of state or maturity.
…On Thu, Mar 13, 2025 at 2:52 AM Dmitrii Anoshin ***@***.***> wrote:
I'm not against this approach. However, we are now introducing some
framework for receivers emitting structured log records while most of the
receivers wouldn't be able to follow it. So maybe we can start with some
generic functionality like *Automatic Generation of Scope Name and
Version* and *Template-Based Documentation* and apply it to all log
receivers. Then we proceed with other features and clearly mark receivers
emitting structured logs when some specific features are applied to them.
I'm suggesting this approach because it'll bring consistent usage of the
mdatagen in log receivers instead of having this applied only to a couple
of receivers while others are not even mentioned in metadata.yaml.
—
Reply to this email directly, view it on GitHub
<#12571 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEJHBAJ7FNRGY6OTRQCGQAL2UDXHDAVCNFSM6AAAAABYOWLD4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJZGY4TCMJSGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
[image: dmitryax]*dmitryax* left a comment
(open-telemetry/opentelemetry-collector#12571)
<#12571 (comment)>
I'm not against this approach. However, we are now introducing some
framework for receivers emitting structured log records while most of the
receivers wouldn't be able to follow it. So maybe we can start with some
generic functionality like *Automatic Generation of Scope Name and
Version* and *Template-Based Documentation* and apply it to all log
receivers. Then we proceed with other features and clearly mark receivers
emitting structured logs when some specific features are applied to them.
I'm suggesting this approach because it'll bring consistent usage of the
mdatagen in log receivers instead of having this applied only to a couple
of receivers while others are not even mentioned in metadata.yaml.
—
Reply to this email directly, view it on GitHub
<#12571 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEJHBAJ7FNRGY6OTRQCGQAL2UDXHDAVCNFSM6AAAAABYOWLD4SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJZGY4TCMJSGQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> ### Description This PR introduces the foundational changes necessary for supporting `logs` data in the `mdatagen` tool. #### mdatagen files for logs This update includes the generation of `generated_logs.go` and `generated_logs_test.go`. These files are specifically for receiver and scraper components that support `logs` data, enabling initial log handling capabilities. #### Introducing LogsBuilder This PR introduced a `LogsBuilder` similar to the existing `MetricsBuilder`. It provides a structured way to manage log data with the following functions: 1. `Emit(...ResourceLogsOption)` Similar to `Emit` function in MetricsBuilder 2. `EmitForResource(...ResourceLogsOption)` Similar to `EmitForResource` function in MetricsBuilder 3. `AppendLogRecord(plog.LogRecord)` This function appends a log record to an internal buffer. The buffered log records are used to construct a `ScopeLog` when the `Emit()` or `EmitForResource()` functions are called. Scope name and version are automatically generated. #### Next steps * Add more test cases to LogsBuilder (e.g. reading test configs) * Add LogsBuilderConfig to read logs property in `metadata.yml` to send structured logs * Update receivers in contrib to use LogsBuilder. #### Example usage: ``` lb := NewLogsBuilder(settings) res := pcommon.NewResource() res.Attributes().PutStr("region", "us-west-1") // append the first log record lr := plog.NewLogRecord() lr.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) lr.Attributes().PutStr("type", "log") lr.Body().SetStr("the first log record") // append the second log record lr2 := plog.NewLogRecord() lr2.SetTimestamp(pcommon.NewTimestampFromTime(time.Now())) lr2.Attributes().PutStr("type", "event") lr2.Body().SetStr("the second log record") lb.AppendLogRecord(lr) lb.AppendLogRecord(lr2) logs := lb.Emit(WithLogsResource(res)) ``` #### Example output: ``` resourceLogs: - resource: attributes: - key: region value: stringValue: us-west-1 scopeLogs: - logRecords: - attributes: - key: type value: stringValue: log body: stringValue: the first log record spanId: "" timeUnixNano: "1742291226022739000" traceId: "" - attributes: - key: type value: stringValue: event body: stringValue: the second log record spanId: "" timeUnixNano: "1742291226022739000" traceId: "" scope: name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchreceiver version: latest ``` <!-- Issue number if applicable --> ### Link to tracking issue Part of #12571 <!--Describe what testing was performed and which tests were added.--> ### Testing Added <!--Describe the documentation added.--> ### Documentation Added <!--Please delete paragraphs that you did not use before submitting.-->
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This PR added type definition needed for supporting structured events in mdatagen. Note: the NewLogsBuilder function signature is generated dynamically according to logs config: ``` func NewLogsBuilder({{ if .Events }}lbc LogsBuilderConfig, {{ end }}settings {{ .Status.Class }}.Settings) *LogsBuilder {} ``` <!-- Issue number if applicable --> #### Link to tracking issue Part of #12571 <!--Describe what testing was performed and which tests were added.--> #### Testing Added <!--Describe the documentation added.--> #### Documentation Added <!--Please delete paragraphs that you did not use before submitting.-->
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Add functions for processing structured events <!-- Issue number if applicable --> #### Link to tracking issue Part of #12571 <!--Describe what testing was performed and which tests were added.--> #### Testing Added <!--Describe the documentation added.--> #### Documentation Added <!--Please delete paragraphs that you did not use before submitting.-->
…etry#12961) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> Add functions for processing structured events <!-- Issue number if applicable --> Part of open-telemetry#12571 <!--Describe what testing was performed and which tests were added.--> Added <!--Describe the documentation added.--> Added <!--Please delete paragraphs that you did not use before submitting.-->
…etry#12961) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> Add functions for processing structured events <!-- Issue number if applicable --> Part of open-telemetry#12571 <!--Describe what testing was performed and which tests were added.--> Added <!--Describe the documentation added.--> Added <!--Please delete paragraphs that you did not use before submitting.-->
Component(s)
mdatagen
Describe the issue you're reporting
mdatagen supports metrics and telemetry, but not logs, even though the collector supports log collection. Having wrappers generated that support all of the Open Telemetry types would be nice thing.
The text was updated successfully, but these errors were encountered: