add support of OTLP metrics (#66) * add support of OTLP metrics * Update Go version setup in CodeQL workflow * fix(deps): bump x/net, x/sys, x/text, and grpc
diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b070799..f429182 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml
@@ -26,7 +26,7 @@ - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.20' + go-version-file: 'go.mod' # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL
diff --git a/README.md b/README.md index 42e5093..e768b80 100644 --- a/README.md +++ b/README.md
@@ -77,6 +77,46 @@ | `WithEndpoint(endpoint string)` | Sets endpoint to send the metrics to. Default value is `https://${LOGICMONITOR_ACCOUNT}.logicmonitor.com/rest/`.| | `WithAuthentication(authParams utils.AuthParams)` | Sets authentication parameters. | +### OTLP Metrics Ingestion + +This is how you can initialise otlp metrics client: + +```go +import ( + "context" + + "github.com/logicmonitor/lm-data-sdk-go/api/otlpmetrics" + "github.com/logicmonitor/lm-data-sdk-go/utils" + "go.opentelemetry.io/collector/pdata/pmetric" +) + +func main() { + client, err := otlpmetrics.NewLMOTLPMetricIngest(context.Background(), + otlpmetrics.WithAuthentication(utils.AuthParams{ /* ... */ }), + otlpmetrics.WithOTLPMetricBatchingDisabled(), + ) + if err != nil { + panic(err) + } + _, err = client.SendOTLPMetrics(context.Background(), pmetric.NewMetrics()) +} +``` + +#### Options + +| Option | Description | +| -------------------- |:----------------------------------:| +| `WithOTLPMetricBatchingInterval(batchinterval time.Duration)` | Sets time interval between OTLP metric batches. Default is `10s`. | +| `WithOTLPMetricBatchingDisabled()` | Disables SDK-side batching. Default is enabled. | +| `WithGzipCompression(gzip bool)` | Enables / disables gzip. Default is enabled. | +| `WithRateLimit(requestCount int)` | Request quota per minute. Default is `100`. | +| `WithHTTPClient(client *http.Client)` | Custom HTTP client. | +| `WithEndpoint(endpoint string)` | Base REST URL. Default is `https://${LOGICMONITOR_ACCOUNT}.logicmonitor.com/rest`. The SDK appends `/api/v1/metrics`. | +| `WithAuthentication(authParams utils.AuthParams)` | Authentication parameters (collector credentials, LMv1, or bearer). | +| `WithCollectorID(id string)` | Sets the `Collector-ID` request header. | +| `WithUserAgent(userAgent string)` | Sets the User-Agent header. | +| `WithRateLimiterDisabled()` | Disables the SDK rate limiter. | + ### Logs Ingestion This is how you can initialise logs client:
diff --git a/api/otlpmetrics/options.go b/api/otlpmetrics/options.go new file mode 100644 index 0000000..347062b --- /dev/null +++ b/api/otlpmetrics/options.go
@@ -0,0 +1,97 @@ +package otlpmetrics + +import ( + "net/http" + "time" + + ratelimiter "github.com/logicmonitor/lm-data-sdk-go/pkg/ratelimiter" + "github.com/logicmonitor/lm-data-sdk-go/utils" +) + +type Option func(*LMOTLPMetricIngest) error + +// WithOTLPMetricBatchingInterval sets the interval between OTLP metric batches. +func WithOTLPMetricBatchingInterval(batchingInterval time.Duration) Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.batch.interval = batchingInterval + return nil + } +} + +// WithOTLPMetricBatchingDisabled disables SDK-side batching of OTLP metrics. +func WithOTLPMetricBatchingDisabled() Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.batch.enabled = false + return nil + } +} + +// WithAuthentication sets authentication parameters if not taken from the environment. +func WithAuthentication(authProvider utils.AuthParams) Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.auth = authProvider + return nil + } +} + +// WithGzipCompression enables or disables gzip compression of the OTLP payload. +// Gzip is enabled by default. +func WithGzipCompression(gzip bool) Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.gzip = gzip + return nil + } +} + +// WithRateLimit limits OTLP metric requests per minute. +func WithRateLimit(requestCount int) Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.rateLimiterSetting.RequestCount = requestCount + return nil + } +} + +// WithHTTPClient sets a custom HTTP client. +func WithHTTPClient(client *http.Client) Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.client = client + return nil + } +} + +// WithEndpoint sets the base REST URL (SDK appends /api/v1/metrics). +func WithEndpoint(endpoint string) Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.url = endpoint + return nil + } +} + +// WithCollectorID sets Collector-ID on the request header. +func WithCollectorID(collectorID string) Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.collectorID = collectorID + return nil + } +} + +// WithUserAgent sets the User-Agent header. +func WithUserAgent(userAgent string) Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.userAgent = userAgent + return nil + } +} + +func WithRateLimiterDisabled() Option { + return func(ingest *LMOTLPMetricIngest) error { + ingest.rateLimiter = &ratelimiter.NoopRateLimiter{} + return nil + } +} + +type SendOTLPMetricsOptionalParameters struct{} + +func NewSendOTLPMetricsOptionalParameters() *SendOTLPMetricsOptionalParameters { + return &SendOTLPMetricsOptionalParameters{} +}
diff --git a/api/otlpmetrics/otlpmetrics.go b/api/otlpmetrics/otlpmetrics.go new file mode 100644 index 0000000..62925dd --- /dev/null +++ b/api/otlpmetrics/otlpmetrics.go
@@ -0,0 +1,300 @@ +package otlpmetrics + +import ( + "context" + "encoding/json" + "fmt" + "io" + "log" + "net/http" + "strconv" + "sync" + "time" + + "github.com/logicmonitor/lm-data-sdk-go/internal/client" + "github.com/logicmonitor/lm-data-sdk-go/model" + rateLimiter "github.com/logicmonitor/lm-data-sdk-go/pkg/ratelimiter" + "github.com/logicmonitor/lm-data-sdk-go/utils" + "go.opentelemetry.io/collector/pdata/pmetric" + "go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp" +) + +const ( + otlpMetricIngestURI = "/api/v1/metrics" + defaultBatchingInterval = 10 * time.Second + maxHTTPResponseReadBytes = 64 * 1024 + headerRetryAfter = "Retry-After" +) + +// LMOTLPMetricIngest sends native OTLP metrics to LogicMonitor AMP. +type LMOTLPMetricIngest struct { + client *http.Client + url string + auth utils.AuthParams + gzip bool + rateLimiterSetting rateLimiter.MetricsRateLimiterSetting + rateLimiter rateLimiter.RateLimiter + batch *otlpMetricBatch + collectorID string + userAgent string +} + +type lmOTLPMetricIngestRequest struct { + metricsPayload model.OTLPMetricsPayload +} + +type LMOTLPMetricIngestResponse struct { + Success bool `json:"success"` + Message string `json:"message"` +} + +type SendOTLPMetricResponse struct { + StatusCode int `json:"statusCode"` + Success bool `json:"success"` + Message string `json:"message"` + + RetryAfter int `json:"retryAfter"` + + Error error `json:"error"` + MultiStatus []struct { + Code float64 `json:"code"` + Error string `json:"error"` + } `json:"multiStatus"` +} + +type otlpMetricBatch struct { + enabled bool + data *lmOTLPMetricIngestRequest + interval time.Duration + lock *sync.Mutex +} + +func NewLMOTLPMetricIngest(ctx context.Context, opts ...Option) (*LMOTLPMetricIngest, error) { + ingest := LMOTLPMetricIngest{ + client: client.New(), + auth: utils.AuthParams{}, + gzip: true, + rateLimiterSetting: rateLimiter.MetricsRateLimiterSetting{}, + batch: NewOTLPMetricBatch(), + } + + for _, opt := range opts { + if err := opt(&ingest); err != nil { + return nil, err + } + } + + var err error + if ingest.url == "" { + metricsURL, err := utils.URL() + if err != nil { + return nil, fmt.Errorf("NewLMOTLPMetricIngest: failed to create metrics URL: %v", err) + } + ingest.url = metricsURL + } + + if ingest.rateLimiter == nil { + ingest.rateLimiter, err = rateLimiter.NewMetricsRateLimiter(ingest.rateLimiterSetting) + if err != nil { + return nil, err + } + go ingest.rateLimiter.Run(ctx) + } + + if ingest.batch.enabled { + go ingest.processBatch(ctx) + } + return &ingest, nil +} + +func NewOTLPMetricBatch() *otlpMetricBatch { + return &otlpMetricBatch{ + enabled: true, + interval: defaultBatchingInterval, + lock: &sync.Mutex{}, + data: &lmOTLPMetricIngestRequest{ + metricsPayload: model.OTLPMetricsPayload{ + MetricData: pmetric.NewMetrics(), + }, + }, + } +} + +func (ingest *LMOTLPMetricIngest) processBatch(ctx context.Context) { + for { + select { + case <-ctx.Done(): + return + case <-time.NewTicker(ingest.batch.batchInterval()).C: + req := ingest.batch.combineBatchedRequests() + if req == nil { + continue + } + _, err := ingest.export(req) + if err != nil { + log.Println(err) + } + } + } +} + +func (batch *otlpMetricBatch) batchInterval() time.Duration { + return batch.interval +} + +// SendOTLPMetrics is the entry point for native OTLP metric data. +func (ingest *LMOTLPMetricIngest) SendOTLPMetrics(ctx context.Context, md pmetric.Metrics, o ...SendOTLPMetricsOptionalParameters) (*SendOTLPMetricResponse, error) { + req, err := ingest.buildRequest(ctx, md, o...) + if err != nil { + return nil, err + } + + if ingest.batch.enabled { + ingest.batch.pushToBatch(req) + return nil, nil + } + return ingest.export(req) +} + +func (ingest *LMOTLPMetricIngest) buildRequest(ctx context.Context, md pmetric.Metrics, o ...SendOTLPMetricsOptionalParameters) (*lmOTLPMetricIngestRequest, error) { + return &lmOTLPMetricIngestRequest{ + metricsPayload: model.OTLPMetricsPayload{MetricData: md}, + }, nil +} + +func (batch *otlpMetricBatch) pushToBatch(req *lmOTLPMetricIngestRequest) { + batch.lock.Lock() + defer batch.lock.Unlock() + req.metricsPayload.MetricData.ResourceMetrics().MoveAndAppendTo(batch.data.metricsPayload.MetricData.ResourceMetrics()) +} + +func (batch *otlpMetricBatch) combineBatchedRequests() *lmOTLPMetricIngestRequest { + batch.lock.Lock() + defer batch.lock.Unlock() + + if batch.data.metricsPayload.MetricData.DataPointCount() == 0 { + return nil + } + + req := &lmOTLPMetricIngestRequest{metricsPayload: batch.data.metricsPayload} + if batch.enabled { + batch.data.metricsPayload.MetricData = pmetric.NewMetrics() + } + return req +} + +func (ingest *LMOTLPMetricIngest) export(req *lmOTLPMetricIngestRequest) (*SendOTLPMetricResponse, error) { + if req.metricsPayload.MetricData.DataPointCount() == 0 { + return nil, nil + } + headers := make(map[string]string) + headers["Content-Type"] = "application/x-protobuf" + + if ingest.collectorID != "" { + headers["Collector-ID"] = ingest.collectorID + } + + body, err := pmetricotlp.NewExportRequestFromMetrics(req.metricsPayload.MetricData).MarshalProto() + if err != nil { + return nil, err + } + + token, err := ingest.auth.GetCredentials(http.MethodPost, otlpMetricIngestURI, body) + if err != nil { + return nil, fmt.Errorf("LMOTLPMetricIngest.export: failed to get auth credentials: %w", err) + } + + cfg := client.RequestConfig{ + Client: ingest.client, + RateLimiter: ingest.rateLimiter, + Url: ingest.url, + Body: body, + Uri: otlpMetricIngestURI, + Method: http.MethodPost, + Token: token, + Gzip: ingest.gzip, + Headers: headers, + UserAgent: ingest.userAgent, + } + + resp, err := client.DoRequest(context.Background(), cfg) + if err != nil { + return nil, fmt.Errorf("LMOTLPMetricIngest.export: otlp metrics export request failed: %w", err) + } + parsedResp, err := readResponse(resp) + if err != nil { + return nil, fmt.Errorf("LMOTLPMetricIngest.export: failed to read response: %w", err) + } + + sendResp := &SendOTLPMetricResponse{ + StatusCode: parsedResp.StatusCode, + Success: parsedResp.Success, + Message: parsedResp.Message, + Error: parsedResp.Error, + MultiStatus: parsedResp.MultiStatus, + RetryAfter: parsedResp.RetryAfter, + } + + if !sendResp.Success { + return sendResp, fmt.Errorf("LMOTLPMetricIngest.export: failed to export otlp metrics: %w", sendResp.Error) + } + return sendResp, nil +} + +func readResponse(resp *http.Response) (*model.OTLPMetricsIngestAPIResponse, error) { + defer func() { + io.CopyN(io.Discard, resp.Body, maxHTTPResponseReadBytes) // nolint:errcheck + resp.Body.Close() + }() + + if resp.StatusCode >= 200 && resp.StatusCode <= 299 { + return &model.OTLPMetricsIngestAPIResponse{ + StatusCode: resp.StatusCode, + Success: true, + }, nil + } + + parsedResponse := decodeResponse(resp) + + var formattedErr error + if parsedResponse != nil { + formattedErr = fmt.Errorf( + "readResponse: error exporting items, request to %s responded with HTTP Status Code %d, Message=%s", + resp.Request.URL, resp.StatusCode, parsedResponse.Message) + } else { + formattedErr = fmt.Errorf( + "readResponse: error exporting items, request to %s responded with HTTP Status Code %d", + resp.Request.URL, resp.StatusCode) + } + retryAfter := 0 + if val := resp.Header.Get(headerRetryAfter); val != "" { + if seconds, err2 := strconv.Atoi(val); err2 == nil { + retryAfter = seconds + } + } + return &model.OTLPMetricsIngestAPIResponse{ + StatusCode: resp.StatusCode, + Success: false, + Error: formattedErr, + RetryAfter: retryAfter, + }, nil +} + +func decodeResponse(resp *http.Response) *LMOTLPMetricIngestResponse { + var ingestResponse *LMOTLPMetricIngestResponse + if resp.StatusCode >= 400 && resp.StatusCode <= 599 { + maxRead := resp.ContentLength + if maxRead == -1 || maxRead > maxHTTPResponseReadBytes { + maxRead = maxHTTPResponseReadBytes + } + respBytes := make([]byte, maxRead) + n, err := io.ReadFull(resp.Body, respBytes) + if err == nil && n > 0 { + ingestResponse = &LMOTLPMetricIngestResponse{} + if json.Unmarshal(respBytes, ingestResponse) != nil { + ingestResponse = nil + } + } + } + return ingestResponse +}
diff --git a/api/otlpmetrics/otlpmetrics_test.go b/api/otlpmetrics/otlpmetrics_test.go new file mode 100644 index 0000000..1442de2 --- /dev/null +++ b/api/otlpmetrics/otlpmetrics_test.go
@@ -0,0 +1,157 @@ +package otlpmetrics + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/http/httptest" + "sync" + "testing" + "time" + + "github.com/logicmonitor/lm-data-sdk-go/internal/testutil" + "github.com/logicmonitor/lm-data-sdk-go/model" + rateLimiter "github.com/logicmonitor/lm-data-sdk-go/pkg/ratelimiter" + "github.com/logicmonitor/lm-data-sdk-go/utils" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/pdata/pcommon" + "go.opentelemetry.io/collector/pdata/pmetric" +) + +func TestNewLMOTLPMetricIngest(t *testing.T) { + testutil.SetTestLMEnvVars() + defer testutil.CleanupTestLMEnvVars() + + t.Run("should return instance with default values", func(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + client, err := NewLMOTLPMetricIngest(ctx) + assert.NoError(t, err) + assert.Equal(t, true, client.batch.enabled) + assert.Equal(t, defaultBatchingInterval, client.batch.interval) + assert.Equal(t, true, client.gzip) + assert.NotNil(t, client.client) + }) + + t.Run("should apply options", func(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + client, err := NewLMOTLPMetricIngest(ctx, WithOTLPMetricBatchingInterval(5*time.Second)) + assert.NoError(t, err) + assert.Equal(t, 5*time.Second, client.batch.interval) + }) +} + +func TestSendOTLPMetrics(t *testing.T) { + testutil.SetTestLMEnvVars() + defer testutil.CleanupTestLMEnvVars() + + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + assert.Equal(t, otlpMetricIngestURI, r.URL.Path) + assert.Equal(t, "application/x-protobuf", r.Header.Get("Content-Type")) + response := LMOTLPMetricIngestResponse{ + Success: true, + Message: "Accepted", + } + w.WriteHeader(http.StatusAccepted) + assert.NoError(t, json.NewEncoder(w).Encode(&response)) + })) + defer ts.Close() + + t.Run("send without batching", func(t *testing.T) { + rl, _ := rateLimiter.NewMetricsRateLimiter(rateLimiter.MetricsRateLimiterSetting{RequestCount: 100}) + e := &LMOTLPMetricIngest{ + client: ts.Client(), + url: ts.URL, + auth: utils.AuthParams{}, + rateLimiter: rl, + batch: &otlpMetricBatch{enabled: false}, + } + + resp, err := e.SendOTLPMetrics(context.Background(), createMetricData()) + assert.NoError(t, err) + assert.True(t, resp.Success) + }) + + t.Run("send with batching enabled", func(t *testing.T) { + rl, _ := rateLimiter.NewMetricsRateLimiter(rateLimiter.MetricsRateLimiterSetting{RequestCount: 100}) + e := &LMOTLPMetricIngest{ + client: ts.Client(), + url: ts.URL, + auth: utils.AuthParams{}, + rateLimiter: rl, + batch: &otlpMetricBatch{ + enabled: true, + interval: 1 * time.Second, + lock: &sync.Mutex{}, + data: &lmOTLPMetricIngestRequest{metricsPayload: model.OTLPMetricsPayload{MetricData: pmetric.NewMetrics()}}, + }, + } + _, err := e.SendOTLPMetrics(context.Background(), createMetricData()) + assert.NoError(t, err) + }) +} + +func TestPushToBatch(t *testing.T) { + ingest := LMOTLPMetricIngest{batch: NewOTLPMetricBatch()} + testData := createMetricData() + n := testData.DataPointCount() + req, err := ingest.buildRequest(context.Background(), testData) + assert.NoError(t, err) + + before := ingest.batch.data.metricsPayload.MetricData.DataPointCount() + ingest.batch.pushToBatch(req) + assert.Equal(t, before+n, ingest.batch.data.metricsPayload.MetricData.DataPointCount()) +} + +func TestReadResponse(t *testing.T) { + t.Run("success response", func(t *testing.T) { + ingestResponse, err := readResponse(&http.Response{ + StatusCode: http.StatusAccepted, + Body: ioutil.NopCloser(bytes.NewBufferString("Accepted")), + }) + require.NoError(t, err) + assert.Equal(t, model.OTLPMetricsIngestAPIResponse{ + Success: true, + StatusCode: http.StatusAccepted, + }, *ingestResponse) + }) + + t.Run("error response", func(t *testing.T) { + data := []byte(`{ + "success": false, + "message": "Too Many Requests" + }`) + ingestResponse, err := readResponse(&http.Response{ + StatusCode: http.StatusTooManyRequests, + ContentLength: int64(len(data)), + Request: httptest.NewRequest(http.MethodPost, "https://example.logicmonitor.com"+otlpMetricIngestURI, nil), + Body: ioutil.NopCloser(bytes.NewReader(data)), + }) + require.NoError(t, err) + assert.Equal(t, model.OTLPMetricsIngestAPIResponse{ + Success: false, + StatusCode: http.StatusTooManyRequests, + Error: fmt.Errorf("readResponse: error exporting items, request to https://example.logicmonitor.com%s responded with HTTP Status Code 429, Message=Too Many Requests", otlpMetricIngestURI), + }, *ingestResponse) + }) +} + +func createMetricData() pmetric.Metrics { + md := pmetric.NewMetrics() + rm := md.ResourceMetrics().AppendEmpty() + sm := rm.ScopeMetrics().AppendEmpty() + m := sm.Metrics().AppendEmpty() + m.SetName("test.gauge") + g := m.SetEmptyGauge() + dp := g.DataPoints().AppendEmpty() + dp.SetDoubleValue(1.5) + dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(100, 0))) + return md +}
diff --git a/go.mod b/go.mod index d891925..3066c9e 100644 --- a/go.mod +++ b/go.mod
@@ -18,11 +18,11 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/net v0.55.0 // indirect - golang.org/x/sys v0.45.0 // indirect - golang.org/x/text v0.37.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 // indirect - google.golang.org/grpc v1.82.1 // indirect + golang.org/x/net v0.58.0 // indirect + golang.org/x/sys v0.47.0 // indirect + golang.org/x/text v0.41.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa // indirect + google.golang.org/grpc v1.83.2 // indirect google.golang.org/protobuf v1.36.11 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect )
diff --git a/go.sum b/go.sum index 385ee8f..00eddc6 100644 --- a/go.sum +++ b/go.sum
@@ -44,16 +44,16 @@ go.opentelemetry.io/auto/sdk v1.2.1/go.mod h1:KRTj+aOaElaLi+wW1kO/DZRXwkF4C5xPbEe3ZiIhN7Y= go.opentelemetry.io/collector/pdata v1.0.0 h1:ECP2jnLztewsHmL1opL8BeMtWVc7/oSlKNhfY9jP8ec= go.opentelemetry.io/collector/pdata v1.0.0/go.mod h1:TsDFgs4JLNG7t6x9D8kGswXUz4mme+MyNChHx8zSF6k= -go.opentelemetry.io/otel v1.43.0 h1:mYIM03dnh5zfN7HautFE4ieIig9amkNANT+xcVxAj9I= -go.opentelemetry.io/otel v1.43.0/go.mod h1:JuG+u74mvjvcm8vj8pI5XiHy1zDeoCS2LB1spIq7Ay0= -go.opentelemetry.io/otel/metric v1.43.0 h1:d7638QeInOnuwOONPp4JAOGfbCEpYb+K6DVWvdxGzgM= -go.opentelemetry.io/otel/metric v1.43.0/go.mod h1:RDnPtIxvqlgO8GRW18W6Z/4P462ldprJtfxHxyKd2PY= -go.opentelemetry.io/otel/sdk v1.43.0 h1:pi5mE86i5rTeLXqoF/hhiBtUNcrAGHLKQdhg4h4V9Dg= -go.opentelemetry.io/otel/sdk v1.43.0/go.mod h1:P+IkVU3iWukmiit/Yf9AWvpyRDlUeBaRg6Y+C58QHzg= -go.opentelemetry.io/otel/sdk/metric v1.43.0 h1:S88dyqXjJkuBNLeMcVPRFXpRw2fuwdvfCGLEo89fDkw= -go.opentelemetry.io/otel/sdk/metric v1.43.0/go.mod h1:C/RJtwSEJ5hzTiUz5pXF1kILHStzb9zFlIEe85bhj6A= -go.opentelemetry.io/otel/trace v1.43.0 h1:BkNrHpup+4k4w+ZZ86CZoHHEkohws8AY+WTX09nk+3A= -go.opentelemetry.io/otel/trace v1.43.0/go.mod h1:/QJhyVBUUswCphDVxq+8mld+AvhXZLhe+8WVFxiFff0= +go.opentelemetry.io/otel v1.44.0 h1:JjwHmHpA4iZ3wBxluu2fbbE7j4kqlE8jXyAyPXH7HqU= +go.opentelemetry.io/otel v1.44.0/go.mod h1:BMgjTHL9WPRlRjL2oZCBTL4whCGtXch2H4BhOPIAyYc= +go.opentelemetry.io/otel/metric v1.44.0 h1:1w0gILTcHdr3YI+ixLyjemwrVnsMURbTZFrSYCdDdmc= +go.opentelemetry.io/otel/metric v1.44.0/go.mod h1:8O7hanEPBNgEMmybD3s2VBKcgWOCsA6tzHBPODAiquo= +go.opentelemetry.io/otel/sdk v1.44.0 h1:nHYwb9lK+fJPU/dnT6s7W7Z8itMWyqrnVfbheVYrZ58= +go.opentelemetry.io/otel/sdk v1.44.0/go.mod h1:Osuydd3Se74nqjAKxid74N5eC+jfEqfTegHRnq58oK0= +go.opentelemetry.io/otel/sdk/metric v1.44.0 h1:3LlKgI+VjbVsjNRFZJZAJ30WjXC5VkNRks6si09iEfI= +go.opentelemetry.io/otel/sdk/metric v1.44.0/go.mod h1:5B5pMARnXxKhltooO4xUuCBorl65a4EpnTalObqOigA= +go.opentelemetry.io/otel/trace v1.44.0 h1:jxF5CsGYCe74MCRx2X4g7WsY/VBKRqqpNvXlX/6gtIk= +go.opentelemetry.io/otel/trace v1.44.0/go.mod h1:oLl1jrMQAVo6v3GAggN+1VH9VIz9iUSvW53sW1Q8PIE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -65,20 +65,20 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8= -golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww= +golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To= +golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY= -golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc= -golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38= +golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8= +golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -89,10 +89,10 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478 h1:RmoJA1ujG+/lRGNfUnOMfhCy5EipVMyvUE+KNbPbTlw= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260414002931-afd174a4e478/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= -google.golang.org/grpc v1.82.1 h1:NnAxzGRA0677vCa4BUkOAnO5+FfQqVl9iUXeD0IqcGE= -google.golang.org/grpc v1.82.1/go.mod h1:yzTZ1TB1Z3SG+LIYaI+WiE8D5+PZ3ArnrSp8zF3+/ZA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa h1:mZHHdPZl0dbGHCflZgAq/Q468DWVFcU2whhB2KAo8fk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20260526163538-3dc84a4a5aaa/go.mod h1:4Hqkh8ycfw05ld/3BWL7rJOSfebL2Q+DVDeRgYgxUU8= +google.golang.org/grpc v1.83.2 h1:EManeRomTObA0BU7I8vXgg/78uE5MJ9M8B39EX2WscU= +google.golang.org/grpc v1.83.2/go.mod h1:YPI1hK3kDked6iHvgX3tR0y+nX/qpMFKhPgFsokw1S8= google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE= google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
diff --git a/model/ingest.go b/model/ingest.go index a77e70f..7e8e947 100644 --- a/model/ingest.go +++ b/model/ingest.go
@@ -27,6 +27,18 @@ } `json:"multiStatus"` } +type OTLPMetricsIngestAPIResponse struct { + StatusCode int `json:"statusCode"` + Success bool `json:"success"` + Message string `json:"message"` + Error error `json:"error"` + MultiStatus []struct { + Code float64 `json:"code"` + Error string `json:"error"` + } `json:"multiStatus"` + RetryAfter int `json:"retryAfter"` +} + type LogsIngestAPIResponse struct { StatusCode int `json:"statusCode"` Success bool `json:"success"`
diff --git a/model/otlpmetrics.go b/model/otlpmetrics.go new file mode 100644 index 0000000..370dc15 --- /dev/null +++ b/model/otlpmetrics.go
@@ -0,0 +1,7 @@ +package model + +import "go.opentelemetry.io/collector/pdata/pmetric" + +type OTLPMetricsPayload struct { + MetricData pmetric.Metrics +}