Skip to content
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

update the OTLP Exporter to match the changes in the metrics specifications (labels -> attributes) #300

Closed
wants to merge 3 commits into from

Conversation

vvydier
Copy link
Contributor

@vvydier vvydier commented May 12, 2022

labels has been deprecated in otel-proto and attributes are now used in it's place. This was reported by @trevor-dialpad and the OTLP Exporter needed this change if a user uses opentelemetry-swift with along other otel sdk's or uses it with newer version of the otel-collector

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented May 12, 2022

CLA Missing ID CLA Not Signed

@trevor-dialpad
Copy link
Contributor

This should resolve #293

Copy link
Member

@nachoBonafonte nachoBonafonte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you very much

Copy link
Contributor

@trevor-dialpad trevor-dialpad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, some comments I think can be removed though. I'll try to test this on my end later this afternoon too

@@ -54,114 +54,132 @@ struct MetricsAdapter {
guard let gaugeData = $0 as? SumData<Double> else {
break
}
var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleDataPoint()
// var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleDataPoint()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Trevor for catching it, I am cleaning up the commented sections of the code, as I was changing the MetricsAdapter.

gaugeData.labels.forEach {
var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
// var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

case .intGauge:
guard let gaugeData = $0 as? SumData<Int> else {
break
}

var protoDataPoint = Opentelemetry_Proto_Metrics_V1_IntDataPoint()
// var protoDataPoint = Opentelemetry_Proto_Metrics_V1_IntDataPoint()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

protoDataPoint.timeUnixNano = gaugeData.timestamp.timeIntervalSince1970.toNanoseconds
protoDataPoint.startTimeUnixNano = gaugeData.startTimestamp.timeIntervalSince1970.toNanoseconds
gaugeData.labels.forEach {
var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
// var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

case .doubleSum:
guard let sumData = $0 as? SumData<Double> else {
break
}

var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleDataPoint()
protoDataPoint.value = sumData.sum
// var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleDataPoint()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

case .doubleSummary:

guard let summaryData = $0 as? SummaryData<Double> else {
break
}
var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleSummaryDataPoint()
// var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleSummaryDataPoint()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

case .intSum:
guard let sumData = $0 as? SumData<Int> else {
break
}
var protoDataPoint = Opentelemetry_Proto_Metrics_V1_IntDataPoint()
protoDataPoint.value = Int64(sumData.sum)
// var protoDataPoint = Opentelemetry_Proto_Metrics_V1_IntDataPoint()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

protoDataPoint.timeUnixNano = sumData.timestamp.timeIntervalSince1970.toNanoseconds
protoDataPoint.startTimeUnixNano = sumData.startTimestamp.timeIntervalSince1970.toNanoseconds
sumData.labels.forEach {
var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
// var kvp = Opentelemetry_Proto_Common_V1_StringKeyValue()
var kvp = Opentelemetry_Proto_Common_V1_KeyValue()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

case .intSummary:
guard let summaryData = $0 as? SummaryData<Int> else {
break
}
var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleSummaryDataPoint()
// var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleSummaryDataPoint()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

case .intHistogram:
guard let histogramData = $0 as? HistogramData<Int> else {
break
}
var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleHistogramDataPoint()
// var protoDataPoint = Opentelemetry_Proto_Metrics_V1_DoubleHistogramDataPoint()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed I think

@codecov
Copy link

codecov bot commented May 12, 2022

Codecov Report

Merging #300 (c95ac97) into main (1c648c1) will decrease coverage by 0.89%.
The diff coverage is 30.41%.

❗ Current head c95ac97 differs from pull request most recent head 7084ce9. Consider uploading reports for the commit 7084ce9 to get more accurate results

@@            Coverage Diff             @@
##             main     #300      +/-   ##
==========================================
- Coverage   75.35%   74.45%   -0.90%     
==========================================
  Files         361      361              
  Lines       22569    22796     +227     
==========================================
- Hits        17006    16972      -34     
- Misses       5563     5824     +261     
Impacted Files Coverage Δ
...xporters/OpenTelemetryProtocol/proto/logs.pb.swift 0.00% <0.00%> (ø)
.../OpenTelemetryProtocol/proto/logs_service.pb.swift 0.00% <ø> (ø)
...rters/OpenTelemetryProtocol/proto/metrics.pb.swift 22.48% <ø> (+2.78%) ⬆️
...enTelemetryProtocol/proto/metrics_service.pb.swift 63.15% <ø> (ø)
...ters/OpenTelemetryProtocol/proto/resource.pb.swift 90.00% <ø> (ø)
.../OpenTelemetryProtocol/proto/trace_config.pb.swift 0.00% <0.00%> (ø)
...enTelemetryProtocol/proto/trace_service.grpc.swift 84.37% <ø> (ø)
...OpenTelemetryProtocol/proto/trace_service.pb.swift 63.15% <ø> (ø)
.../OpenTelemetryProtocol/metric/MetricsAdapter.swift 31.84% <10.90%> (-1.15%) ⬇️
...orters/OpenTelemetryProtocol/proto/common.pb.swift 38.56% <36.36%> (-11.82%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c648c1...7084ce9. Read the comment docs.

@trevor-dialpad
Copy link
Contributor

I tested this in my environment and it's working great, thanks!

@trevor-dialpad
Copy link
Contributor

@vvydier any updates on this? Is this just waiting on CLA?

@vvydier
Copy link
Contributor Author

vvydier commented May 16, 2022

Yes, waiting on CNCF to resolve the CLA issue. I have opened a case and they are helping to resolve the issue. I will let you as soon as its resolved, the build and test should go through after that. Thanks

@vvydier
Copy link
Contributor Author

vvydier commented May 19, 2022

The problem was that I had the GitHub user.email set to my work email when I committed. I may just re-do this in another PR to get past the EasyCLA issue!
Do you all have any issue if I create another PR with the user.email set correctly to my gmail id (I think that will get me past this error!)

@nachoBonafonte
Copy link
Member

No issues at all, please create another PR

@molssongroup
Copy link

/easycla

This pull request was closed.
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