Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMothra authored Feb 10, 2022
2 parents f944a1c + 1b5765b commit ba726c5
Show file tree
Hide file tree
Showing 72 changed files with 1,236 additions and 604 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/stale@v4
with:
stale-pr-message: 'This PR was marked stale due to lack of activity. It will be closed in 7 days.'
stale-pr-message: 'This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or Pushing will instruct the bot to automatically remove the label. This bot runs once per day.'
close-pr-message: 'Closed as inactive. Feel free to reopen if this PR is still being worked on.'
operations-per-run: 400
days-before-pr-stale: 7
Expand Down
42 changes: 18 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Any exceptions to this are noted in the individual `README.md` files.
If you are new here, please read the getting started docs:

* [logs](./docs/logs/getting-started/README.md)
* [metrics](./docs/metrics/getting-started/README.md) (experimental)
* [metrics](./docs/metrics/getting-started/README.md)
* [trace](./docs/trace/getting-started/README.md)

This repository includes multiple installable components, available on
Expand Down Expand Up @@ -71,6 +71,8 @@ most common customization and extension scenarios:
library](./docs/trace/extending-the-sdk/README.md#instrumentation-library)
* [Building a custom log
exporter/processor/sampler](./docs/logs/extending-the-sdk/README.md)
* [Building a custom metrics
exporter/reader/exemplar](./docs/metrics/extending-the-sdk/README.md)
* [Building a custom trace
exporter/processor/sampler](./docs/trace/extending-the-sdk/README.md)

Expand All @@ -89,38 +91,30 @@ doc](https://docs.google.com/document/d/1yjjD6aBcLxlRazYrawukDgrhZMObwHARJbB9glW
If you have trouble accessing the doc, please get in touch on
[Slack](https://cloud-native.slack.com/archives/C01N3BC2W7Q).

Approvers
([@open-telemetry/dotnet-approvers](https://github.com/orgs/open-telemetry/teams/dotnet-approvers)):

* [Bruno Garcia](https://github.com/bruno-garcia), Sentry
* [Eddy Nakamura](https://github.com/eddynaka), Microsoft
* [Paulo Janotti](https://github.com/pjanotti), Splunk
* [Reiley Yang](https://github.com/reyang), Microsoft
* [Robert Pajak](https://github.com/pellared), Splunk
* [Utkarsh Umesan Pillai](https://github.com/utpilla), Microsoft

*Find more about the approver role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver).*

Maintainers
[Maintainers](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer)
([@open-telemetry/dotnet-maintainers](https://github.com/orgs/open-telemetry/teams/dotnet-maintainers)):

* [Alan West](https://github.com/alanwest), New Relic
* [Cijo Thomas](https://github.com/cijothomas), Microsoft
* [Mike Goldsmith](https://github.com/MikeGoldsmith), Honeycomb
* [Mikel Blanchard](https://github.com/CodeBlanch), CoStar Group
* [Sergey Kanzhelev](https://github.com/SergeyKanzhelev), Google

*Find more about the maintainer role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#maintainer).*
[Approvers](https://github.com/open-telemetry/community/blob/main/community-membership.md#approver)
([@open-telemetry/dotnet-approvers](https://github.com/orgs/open-telemetry/teams/dotnet-approvers)):

Triager
([@open-telemetry/dotnet-triagers](https://github.com/orgs/open-telemetry/teams/dotnet-triagers)):
* [Reiley Yang](https://github.com/reyang), Microsoft
* [Robert Pająk](https://github.com/pellared), Splunk
* [Utkarsh Umesan Pillai](https://github.com/utpilla), Microsoft

* [Victor Lu](https://github.com/victlu), Microsoft
[Emeritus
Maintainer/Approver/Triager](https://github.com/open-telemetry/community/blob/main/community-membership.md#emeritus-maintainerapprovertriager):

*Find more about the triager role in [community
repository](https://github.com/open-telemetry/community/blob/main/community-membership.md#triager).*
* [Bruno Garcia](https://github.com/bruno-garcia)
* [Eddy Nakamura](https://github.com/eddynaka)
* [Liudmila Molkova](https://github.com/lmolkova)
* [Mike Goldsmith](https://github.com/MikeGoldsmith)
* [Paulo Janotti](https://github.com/pjanotti)
* [Sergey Kanzhelev](https://github.com/SergeyKanzhelev)
* [Victor Lu](https://github.com/victlu)

### Thanks to all the people who have contributed

Expand Down
10 changes: 10 additions & 0 deletions docs/metrics/customizing-the-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ using OpenTelemetry.Metrics;
using var meterProvider = Sdk.CreateMeterProviderBuilder().Build();
```

In a typical application, a single `MeterProvider` is created at application
startup and disposed at application shutdown. It is important to ensure that the
provider is not disposed too early. Actual mechanism depends on the application
type. For example, in a typical ASP.NET application, `MeterProvider` is created
in `Application_Start`, and disposed in `Application_End` (both methods part of
Global.asax.cs file) as shown [here](../../../examples/AspNet/Global.asax.cs). In
a typical ASP.NET Core application, `MeterProvider` lifetime is managed by
leveraging the built-in Dependency Injection container as shown
[here](../../../examples/AspNetCore/Startup.cs).

## MeterProvider configuration

`MeterProvider` holds the metrics configuration, which includes the following:
Expand Down
13 changes: 11 additions & 2 deletions docs/metrics/extending-the-sdk/MyExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,23 @@ public override ExportResult Export(in Batch<Metric> batch)
using var scope = SuppressInstrumentationScope.Begin();

var sb = new StringBuilder();
foreach (var record in batch)
foreach (var metric in batch)
{
if (sb.Length > 0)
{
sb.Append(", ");
}

sb.Append($"{record}");
sb.Append($"{metric.Name}");

foreach (ref readonly var metricPoint in metric.GetMetricPoints())
{
sb.Append($"{metricPoint.StartTime}");
foreach (var metricPointTag in metricPoint.Tags)
{
sb.Append($"{metricPointTag.Key} {metricPointTag.Value}");
}
}
}

Console.WriteLine($"{this.name}.Export([{sb}])");
Expand Down
60 changes: 57 additions & 3 deletions docs/metrics/extending-the-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,68 @@

## Exporter

TBD
OpenTelemetry .NET SDK has provided the following built-in metric exporters:

* [Console](../../../src/OpenTelemetry.Exporter.Console/README.md)
* [InMemory](../../../src/OpenTelemetry.Exporter.InMemory/README.md)
* [OpenTelemetryProtocol](../../../src/OpenTelemetry.Exporter.OpenTelemetryProtocol/README.md)
* [Prometheus](../../../src/OpenTelemetry.Exporter.Prometheus/README.md)

Custom exporters can be implemented to send telemetry data to places which are
not covered by the built-in exporters:

* Exporters should derive from `OpenTelemetry.BaseExporter<Metric>` (which
belongs to the [OpenTelemetry](../../../src/OpenTelemetry/README.md) package)
and implement the `Export` method.
* Exporters can optionally implement the `OnShutdown` method.
* Exporters should not throw exceptions from `Export` and
`OnShutdown`.
* Exporters are responsible for any retry logic needed by the scenario. The SDK
does not implement any retry logic.
* Exporters should avoid generating telemetry and causing live-loop, this can be
done via `OpenTelemetry.SuppressInstrumentationScope`.
* Exporters receives a batch of `Metric`, and each `Metric`
can contain 1 or more `MetricPoint`s.
* Exporters should use `Activity.TagObjects` collection instead of
`Activity.Tags` to obtain the full set of attributes (tags).
* Exporters should use `ParentProvider.GetResource()` to get the `Resource`
associated with the provider.

```csharp
class MyExporter : BaseExporter<Metric>
{
public override ExportResult Export(in Batch<Metric> batch)
{
using var scope = SuppressInstrumentationScope.Begin();

foreach (var metric in batch)
{
Console.WriteLine($"Export: {metric.metric}");

foreach (ref readonly var metricPoint in metric.GetMetricPoints())
{
Console.WriteLine($"Export: {metricPoint.StartTime}");
}
}

return ExportResult.Success;
}
}
```

A demo exporter which simply writes metric name and metric point start time
, tags to the console is shown [here](./MyExporter.cs).

Apart from the exporter itself, you should also provide extension methods as
shown [here](./MyExporterExtensions.cs). This allows users to add the Exporter
to the `MeterProvider` as shown in the example [here](./Program.cs).

## Reader

TBD
Not supported.

## Exemplar

TBD
Not supported.

## References
6 changes: 1 addition & 5 deletions docs/metrics/getting-started-prometheus-grafana/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ public static void Main(string[] args)
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddMeter("MyCompany.MyProduct.MyLibrary")
.AddPrometheusExporter(opt =>
{
opt.StartHttpListener = true;
opt.HttpListenerPrefixes = new string[] { $"http://localhost:9184/" };
})
.AddPrometheusExporter(options => { options.StartHttpListener = true; })
.Build();

Console.WriteLine("Press any key to exit");
Expand Down
Loading

0 comments on commit ba726c5

Please sign in to comment.