Skip to content

Commit

Permalink
comments addressed
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas committed Dec 18, 2023
1 parent 55cf6fe commit 85f165a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
11 changes: 5 additions & 6 deletions docs/metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,14 @@ counter.Add(100, readOnlySpanOfTags); // <--- DON'T DO THIS
- When emitting metrics with more than eight tags, the SDK allocates memory on
the hot-path. You SHOULD try to keep the number of tags less than or equal to
eight. If you are exceeding this, check if you can model some of the tags as
Resource, as [shown here](#modelling-static-tags-as-resource).
Resource, as [shown here](#modeling-static-tags-as-resource).

### Modelling static tags as Resource
### Modeling static tags as Resource

Tags such as `MachineName`, `Environment` etc. which are static throughout the
process lifetime should be be modelled as `Resource`, instead of adding them
to each `Activity`. Refer to this
[doc](./customizing-the-sdk/README.md#resource) for details and
examples.
process lifetime should be be modeled as `Resource`, instead of adding them to
each metric measurement. Refer to this
[doc](./customizing-the-sdk/README.md#resource) for details and examples.

## Common issues that lead to missing metrics

Expand Down
4 changes: 2 additions & 2 deletions docs/metrics/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public class Program
public static void Main()
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.ConfigureResource(r => r.AddAttributes(new List<KeyValuePair<string, object>>
.ConfigureResource(resource => resource.AddAttributes(new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("static-attribute1", "v1"),
new KeyValuePair<string, object>("static-attribute2", "v2"),
}))
.ConfigureResource(r => r.AddService("MyServiceName"))
.ConfigureResource(resource => resource.AddService("MyServiceName"))
.AddMeter(Meter1.Name)
.AddMeter(Meter2.Name)

Expand Down
2 changes: 1 addition & 1 deletion docs/metrics/customizing-the-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ provider is built, by calling the `Build()` method on the
`ResourceBuilder` offers various methods to construct resource comprising of
attributes from various sources. For example, `AddService()` adds
[Service](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/resource/README.md#service)
resource. `AddAttributes` can be used to add any additional attribute to the
resource. `AddAttributes` can be used to add any additional attributes to the
`Resource`. It also allows adding `ResourceDetector`s.

It is recommended to model attributes that are static throughout the lifetime of
Expand Down
4 changes: 2 additions & 2 deletions docs/trace/customizing-the-sdk/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public static void Main()
// The following adds subscription to activities from all Activity Sources
// whose name starts with "AbcCompany.XyzProduct.".
.AddSource("AbcCompany.XyzProduct.*")
.ConfigureResource(r => r.AddAttributes(new List<KeyValuePair<string, object>>
.ConfigureResource(resource => resource.AddAttributes(new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("static-attribute1", "v1"),
new KeyValuePair<string, object>("static-attribute2", "v2"),
}))
.ConfigureResource(r => r.AddService("MyServiceName"))
.ConfigureResource(resource => resource.AddService("MyServiceName"))
.AddConsoleExporter()
.Build();

Expand Down

0 comments on commit 85f165a

Please sign in to comment.