Skip to content

Commit 5669d43

Browse files
feat: otel support
Signed-off-by: Maximilian Braun (SAP) <[email protected]>
1 parent c6b8379 commit 5669d43

File tree

4 files changed

+1
-777
lines changed

4 files changed

+1
-777
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ toolchain go1.24.0
77
require (
88
github.com/dynatrace-ace/dynatrace-go-api-client/api/v2/environment/dynatrace v0.0.0-20210816162345-de2eacc8ac9a
99
github.com/go-logr/logr v1.4.2
10-
github.com/google/go-cmp v0.6.0
1110
github.com/google/uuid v1.6.0
1211
github.com/hashicorp/golang-lru v0.5.1
1312
github.com/openmcp-project/controller-utils v0.4.2
@@ -44,6 +43,7 @@ require (
4443
github.com/golang/protobuf v1.5.4 // indirect
4544
github.com/google/btree v1.1.3 // indirect
4645
github.com/google/gnostic-models v0.6.9 // indirect
46+
github.com/google/go-cmp v0.6.0 // indirect
4747
github.com/google/gofuzz v1.2.0 // indirect
4848
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
4949
github.com/josharian/intern v1.0.0 // indirect

internal/client/client.go

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,6 @@ import (
88
dyn "github.com/dynatrace-ace/dynatrace-go-api-client/api/v2/environment/dynatrace"
99
)
1010

11-
// AbstractDynatraceClient This interface is a wrapper for the dynatrace-go-client, this interface only implements functions regarding metrics.
12-
// This wrapper also includes the ability to add metadata to your metric which uses the SettingsObjectAPI in the background.
13-
type AbstractDynatraceClient interface {
14-
NewClient(url *string, token string) *dyn.APIClient
15-
16-
// Metrics: Speak directly to MetricsAPI
17-
SendMetric(ctx context.Context, metric MetricMetadata) (*http.Response, error)
18-
GetMetric(ctx context.Context, id string) (dyn.MetricDescriptor, *http.Response, error)
19-
GetAllMetrics(ctx context.Context) (dyn.MetricDescriptorCollection, *http.Response, error)
20-
DeleteMetric(ctx context.Context, id string) (*http.Response, error)
21-
22-
// Metrics Metadata: Speaks to SettingsObjectAPI
23-
SendMetricMetadata(ctx context.Context, metric MetricMetadata) ([]dyn.SettingsObjectResponse, *http.Response, error)
24-
GetMetricMetadata(ctx context.Context, id string) (dyn.ObjectsList, *http.Response, error)
25-
DeleteMetricMetadata(ctx context.Context, objectID string) (*http.Response, error)
26-
UpdateMetricMetadata(ctx context.Context) (dyn.SettingsObjectResponse, *http.Response, error)
27-
}
28-
2911
// DynatraceClient is a wrapper for the dynatrace-go-client, this interface only implements functions regarding metrics.
3012
type DynatraceClient struct {
3113
Client *dyn.APIClient
@@ -77,61 +59,3 @@ func (d *DynatraceClient) SendMetric(ctx context.Context, metric MetricMetadata)
7759

7860
return res, err
7961
}
80-
81-
// GetAllMetrics returns all available metrics that Dynatrace has to over, this is not limited to anything.
82-
func (d *DynatraceClient) GetAllMetrics(ctx context.Context) (dyn.MetricDescriptorCollection, *http.Response, error) {
83-
coll, res, err := d.Client.MetricsApi.AllMetrics(ctx).Execute()
84-
return coll, res, err
85-
}
86-
87-
// GetMetric get a specific metric
88-
// id: id of the metric you want (not the display name)
89-
func (d *DynatraceClient) GetMetric(ctx context.Context, id string) (dyn.MetricDescriptor, *http.Response, error) {
90-
des, res, err := d.Client.MetricsApi.Metric(ctx, id).Execute()
91-
return des, res, err
92-
}
93-
94-
// DeleteMetric deletes a metric
95-
// id: id of the metric you want (not the display name)
96-
func (d *DynatraceClient) DeleteMetric(ctx context.Context, id string) (*http.Response, error) {
97-
res, err := d.Client.MetricsApi.Delete(ctx, id).Execute()
98-
return res, err
99-
}
100-
101-
// SendMetricMetadata sends the metadata of the metric
102-
// this is a big request, this could cause overhead if send with every single datapoint
103-
func (d *DynatraceClient) SendMetricMetadata(ctx context.Context, metric MetricMetadata) ([]dyn.SettingsObjectResponse, *http.Response, error) {
104-
settings, err := metric.GenerateSettingsObjects()
105-
if err != nil {
106-
return []dyn.SettingsObjectResponse{}, &http.Response{}, err
107-
}
108-
collPost, resPost, errPost := d.Client.SettingsObjectsApi.PostSettingsObjects(ctx).SettingsObjectCreate(settings).Execute()
109-
return collPost, resPost, errPost
110-
}
111-
112-
// GetMetricMetadata gets the metadata of a specific metric
113-
// id: id of the metric you want (not the display name)
114-
func (d *DynatraceClient) GetMetricMetadata(ctx context.Context, id string) (dyn.ObjectsList, *http.Response, error) {
115-
coll, res, err := d.Client.SettingsObjectsApi.GetSettingsObjects(ctx).SchemaIds("builtin:metric.metadata").Scopes("metric-" + id).Execute()
116-
return coll, res, err
117-
}
118-
119-
// DeleteMetricMetadata deletes the metadata of a specific metric
120-
// objectId: this id can be optained by making a get request (is not the normal id of an metric)
121-
func (d *DynatraceClient) DeleteMetricMetadata(ctx context.Context, objectID string) (*http.Response, error) {
122-
resDel, errDel := d.Client.SettingsObjectsApi.DeleteSettingsObjectByObjectId(ctx, objectID).Execute()
123-
return resDel, errDel
124-
}
125-
126-
// UpdateMetricMetadata updates the metadata of a specific metric
127-
// objectId: this id can be optained by making a get request (is not the normal id of an metric)
128-
// metric: the updated complete metricMetadata object
129-
// updateToken: can again be obtained by making a get request for the metric you want to update
130-
func (d *DynatraceClient) UpdateMetricMetadata(ctx context.Context, objectID string, metric MetricMetadata, updateToken string) (dyn.SettingsObjectResponse, *http.Response, error) {
131-
settings, err := metric.GenerateUpdateSettings(objectID, metric, updateToken)
132-
if err != nil {
133-
return dyn.SettingsObjectResponse{}, &http.Response{}, err
134-
}
135-
colUpd, resUpd, errUpd := d.Client.SettingsObjectsApi.PutSettingsObjectByObjectId(ctx, objectID).SettingsObjectUpdate(settings).Execute()
136-
return colUpd, resUpd, errUpd
137-
}

0 commit comments

Comments
 (0)