You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Metrics will be sent to StatsD automatically via the PeriodicReader
75
+
}
76
+
```
77
+
78
+
## Using Both Prometheus and StatsD
79
+
80
+
You can also configure both Prometheus and StatsD exporters simultaneously:
81
+
82
+
```go
83
+
// Configure both Prometheus and StatsD
84
+
prometheusConfig:= &metrics.PrometheusConfig{
85
+
ListenAddress: "127.0.0.1:9090",
86
+
HandlerPath: "/metrics",
87
+
}
88
+
89
+
statsdConfig:= &metrics.StatsdConfig{
90
+
HostPort: "localhost:8125",
91
+
Prefix: "temporal",
92
+
Reporter: metrics.StatsdReporterConfig{
93
+
TagSeparator: ",",
94
+
},
95
+
}
96
+
97
+
// Create provider with both exporters
98
+
provider, err:= metrics.NewOpenTelemetryProvider(
99
+
logger,
100
+
prometheusConfig, // Prometheus config
101
+
clientConfig,
102
+
false,
103
+
statsdConfig, // StatsD config
104
+
)
105
+
```
106
+
107
+
## Metric Types Supported
108
+
109
+
The StatsD exporter supports the following OpenTelemetry metric types:
110
+
111
+
### Counters (Sum metrics)
112
+
-**Monotonic sums**: Exported as StatsD counters using `Inc()`
113
+
-**Non-monotonic sums**: Exported as StatsD gauges using `Gauge()`
114
+
115
+
### Gauges
116
+
- Exported as StatsD gauges using `Gauge()`
117
+
118
+
### Histograms
119
+
- Exported as multiple StatsD metrics:
120
+
-`{metric_name}.count`: Total count of observations
121
+
-`{metric_name}.sum`: Sum of all observed values
122
+
-`{metric_name}.bucket_le_{bound}`: Count of observations in each bucket
123
+
124
+
## Configuration Options
125
+
126
+
### StatsdConfig Fields
127
+
128
+
-`HostPort`: The address of the StatsD server (e.g., "localhost:8125")
129
+
-`Prefix`: A prefix to add to all metric names
130
+
-`Reporter.TagSeparator`: The separator to use for StatsD tags (default: ",")
131
+
132
+
### Notes
133
+
134
+
- The StatsD exporter uses the `github.com/cactus/go-statsd-client/v5` library
135
+
- Metrics are sent via UDP, so there's no guarantee of delivery
136
+
- The exporter automatically converts OpenTelemetry attributes to StatsD tags
137
+
- Float64 values are converted to int64 for StatsD compatibility where necessary
138
+
- The exporter uses a PeriodicReader to automatically send metrics at regular intervals
139
+
140
+
## Error Handling
141
+
142
+
The StatsD exporter logs errors but doesn't fail the application if StatsD is unavailable. This ensures that your application continues to work even if the StatsD server is down.
0 commit comments