Skip to content

Add stdout metrics exporter #666

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

Conversation

martin308
Copy link
Contributor

Add stdout metrics exporter

Adds the stdout metrics exporter alongside the trace and log stdout exporter.

Questions:

I've added Encodable/Codable to some of the types to make the JSON encoding a little easier. This doesn't match the pattern in StdoutSpanExporter which uses a wrapper that implements Codable. The StdoutLogExporter relies on the ReadableLogRecord being Codable. Is there a pattern that we want to standardize on for the std out exporters?

The StdoutSpanExporter encodes each SpanData as a separate JSON object whereas the StdoutLogExporter encodes the array of ReadableLogRecord instead of the individual objects. Do we want to standardize on one of these patterns for all of the std out exporters? I couldn't discern from the spec if either of these is the "correct" way to do it.

The other two std out exporters lack tests and so I've not added any for this one. Is this a blocker to merging?

Sample Output:

----------------------------------------
Name: name
Description: description
Unit: m
IsMonotonic: true
Resource: Resource(attributes: ["telemetry.sdk.name": opentelemetry, "service.name": unknown_service:xctest, "telemetry.sdk.language": swift, "telemetry.sdk.version": 1.12.1])
InstrumentationScopeInfo: InstrumentationScopeInfo(name: "name", version: Optional("1.0"), schemaUrl: Optional("https://honeycomb.io"))
Type: DoubleSum
AggregationTemporality: cumulative
DataPoints:
  - StartEpochNanos: 199
    EndEpochNanos: 199
    Attributes: ["attribute": 1.0]
    Exemplars:
      - EpochNanos: 0
        SpanContext: SpanContext{traceId=TraceId{traceId=00000000000000000000000000000000}, spanId=SpanId{spanId=0000000000000000}, traceFlags=TraceFlags{sampled=false}}, isRemote=false
        FilteredAttributes: ["filtered attribute": two]
        Value: 1.0
----------------------------------------
{"description":"description","isMonotonic":true,"resource":{"attributes":{"telemetry.sdk.version":{"string":{"_0":"1.12.1"}},"telemetry.sdk.language":{"string":{"_0":"swift"}},"telemetry.sdk.name":{"string":{"_0":"opentelemetry"}},"service.name":{"string":{"_0":"unknown_service:xctest"}}}},"type":{"DoubleSum":{}},"data":{"points":[{"attributes":{"attribute":{"double":{"_0":1}}},"exemplars":[{"spanContext":{"traceState":{"entries":[]},"traceId":{"idHi":0,"idLo":0},"spanId":{"id":0},"isRemote":false,"traceFlags":{"options":0}},"filteredAttributes":{"filtered attribute":{"string":{"_0":"two"}}},"epochNanos":0}],"startEpochNanos":199,"endEpochNanos":199}],"aggregationTemporality":{"cumulative":{}}},"name":"name","unit":"m","instrumentationScopeInfo":{"schemaUrl":"https:\/\/honeycomb.io","name":"name","version":"1.0"}}

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.52%. Comparing base (7bad8ae) to head (a70e520).
Report is 52 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #666      +/-   ##
==========================================
- Coverage   67.89%   67.52%   -0.38%     
==========================================
  Files         344      352       +8     
  Lines       15169    15876     +707     
==========================================
+ Hits        10299    10720     +421     
- Misses       4870     5156     +286     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nachoBonafonte nachoBonafonte merged commit 0db61a3 into open-telemetry:main Jan 13, 2025
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants