-
Notifications
You must be signed in to change notification settings - Fork 773
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
Add OTLP metrics exporter #2092
Add OTLP metrics exporter #2092
Conversation
Codecov Report
@@ Coverage Diff @@
## metrics #2092 +/- ##
===========================================
- Coverage 77.95% 75.36% -2.59%
===========================================
Files 212 215 +3
Lines 6658 6893 +235
===========================================
+ Hits 5190 5195 +5
- Misses 1468 1698 +230
|
@alanwest Does the OTLPCollector have ability to print the metrics to console? or can it act as prometheus scrape target? |
Yep, it does. Added an option to the metrics example app with instructions on how to run.
The collector does have a prometheus receiver that can be configured to scrape an endpoint, but then this wouldn't be OTLP 😛. |
@@ -19,3 +19,7 @@ | |||
[assembly: InternalsVisibleTo("OpenTelemetry.Tests" + AssemblyInfo.PublicKey)] | |||
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2" + AssemblyInfo.MoqPublicKey)] | |||
[assembly: InternalsVisibleTo("Benchmarks" + AssemblyInfo.PublicKey)] | |||
|
|||
// TODO: Much of the metrics SDK is currently internal. These should be removed once the public API surface area for metrics is defined. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree this is good for short term while we iron-out the public api .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove this now. The MetricItem and its associated classes must be public now. (Even though its highly likely they'll change, when we try for perf tweaks!)
5f6c690
to
741ee92
Compare
src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/MetricItemExtensions.cs
Outdated
Show resolved
Hide resolved
/// <summary> | ||
/// Gets or sets the metric export interval. | ||
/// </summary> | ||
public int MetricExportInterval { get; set; } = 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now just putting these new metric related options here, though it might make sense to make an OtlpMetricsExporterOptions
that derives from OtlpExporterOptions
. Though also there are things like BatchExportProcessorOptions
on this class that may not make sense in the context of metrics.
|
||
var options = new OtlpExporterOptions(); | ||
configure?.Invoke(options); | ||
return builder.AddMetricProcessor(new PushMetricProcessor(new OtlpMetricsExporter(options), options.MetricExportInterval, options.IsDelta)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
OTLP allows both delta and cumulative, so its good to let user pick.
Once views, come, things will be bit more complex, but shouldn't be an issue in 1st release!
{ | ||
if (this.ProcessResource == null) | ||
{ | ||
this.SetResource(this.ParentProvider.GetResource()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might not be working now. but we can address it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Merging! We can add tests and more in future PRs! |
This is a first cut at an OTLP metrics exporter. It compiles, so it must work. No, but really, I'm just manually testing things out right now. I need to add some tests to this PR.
There's some code duplication between this and the trace exporter. I'll plan to handle this by refactoring things on the main branch and then merging main -> metrics.
I can add some benchmarks in a follow up PR.