"""
Get all span-based metrics returns "OK" response
"""fromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.spans_metrics_apiimportSpansMetricsApiconfiguration=Configuration()withApiClient(configuration)asapi_client:api_instance=SpansMetricsApi(api_client)response=api_instance.list_spans_metrics()print(response)
# Get all span-based metrics returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::SpansMetricsAPI.newpapi_instance.list_spans_metrics()
/**
* Get all span-based metrics returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.SpansMetricsApi(configuration);apiInstance.listSpansMetrics().then((data: v2.SpansMetricsResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
// Get all span-based metrics returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewSpansMetricsApi(apiClient)resp,r,err:=api.ListSpansMetrics(ctx)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `SpansMetricsApi.ListSpansMetrics`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `SpansMetricsApi.ListSpansMetrics`:\n%s\n",responseContent)}
Create a metric based on your ingested spans in your organization.
Returns the span-based metric object from the request body when the request is successful.
"""
Get a span-based metric returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.spans_metrics_apiimportSpansMetricsApi# there is a valid "spans_metric" in the systemSPANS_METRIC_DATA_ID=environ["SPANS_METRIC_DATA_ID"]configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=SpansMetricsApi(api_client)response=api_instance.get_spans_metric(metric_id=SPANS_METRIC_DATA_ID,)print(response)
# Get a span-based metric returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::SpansMetricsAPI.new# there is a valid "spans_metric" in the systemSPANS_METRIC_DATA_ID=ENV["SPANS_METRIC_DATA_ID"]papi_instance.get_spans_metric(SPANS_METRIC_DATA_ID)
// Get a span-based metric returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "spans_metric" in the system
SpansMetricDataID:=os.Getenv("SPANS_METRIC_DATA_ID")ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewSpansMetricsApi(apiClient)resp,r,err:=api.GetSpansMetric(ctx,SpansMetricDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `SpansMetricsApi.GetSpansMetric`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `SpansMetricsApi.GetSpansMetric`:\n%s\n",responseContent)}
// Get a span-based metric returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.SpansMetricsApi;importcom.datadog.api.client.v2.model.SpansMetricResponse;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();SpansMetricsApiapiInstance=newSpansMetricsApi(defaultClient);// there is a valid "spans_metric" in the systemStringSPANS_METRIC_DATA_ID=System.getenv("SPANS_METRIC_DATA_ID");try{SpansMetricResponseresult=apiInstance.getSpansMetric(SPANS_METRIC_DATA_ID);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling SpansMetricsApi#getSpansMetric");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
/**
* Get a span-based metric returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.SpansMetricsApi(configuration);// there is a valid "spans_metric" in the system
constSPANS_METRIC_DATA_ID=process.env.SPANS_METRIC_DATA_IDasstring;constparams: v2.SpansMetricsApiGetSpansMetricRequest={metricId: SPANS_METRIC_DATA_ID,};apiInstance.getSpansMetric(params).then((data: v2.SpansMetricResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
// Update a span-based metric returns "OK" response
packagemainimport("context""encoding/json""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "spans_metric" in the system
SpansMetricDataID:=os.Getenv("SPANS_METRIC_DATA_ID")body:=datadogV2.SpansMetricUpdateRequest{Data:datadogV2.SpansMetricUpdateData{Attributes:datadogV2.SpansMetricUpdateAttributes{Compute:&datadogV2.SpansMetricUpdateCompute{IncludePercentiles:datadog.PtrBool(false),},Filter:&datadogV2.SpansMetricFilter{Query:datadog.PtrString("@http.status_code:200 service:my-service-updated"),},GroupBy:[]datadogV2.SpansMetricGroupBy{{Path:"resource_name",TagName:datadog.PtrString("resource_name"),},},},Type:datadogV2.SPANSMETRICTYPE_SPANS_METRICS,},}ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewSpansMetricsApi(apiClient)resp,r,err:=api.UpdateSpansMetric(ctx,SpansMetricDataID,body)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `SpansMetricsApi.UpdateSpansMetric`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `SpansMetricsApi.UpdateSpansMetric`:\n%s\n",responseContent)}
// Update a span-based metric returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.SpansMetricsApi;importcom.datadog.api.client.v2.model.SpansMetricFilter;importcom.datadog.api.client.v2.model.SpansMetricGroupBy;importcom.datadog.api.client.v2.model.SpansMetricResponse;importcom.datadog.api.client.v2.model.SpansMetricType;importcom.datadog.api.client.v2.model.SpansMetricUpdateAttributes;importcom.datadog.api.client.v2.model.SpansMetricUpdateCompute;importcom.datadog.api.client.v2.model.SpansMetricUpdateData;importcom.datadog.api.client.v2.model.SpansMetricUpdateRequest;importjava.util.Collections;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();SpansMetricsApiapiInstance=newSpansMetricsApi(defaultClient);// there is a valid "spans_metric" in the systemStringSPANS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY=System.getenv("SPANS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY");StringSPANS_METRIC_DATA_ID=System.getenv("SPANS_METRIC_DATA_ID");SpansMetricUpdateRequestbody=newSpansMetricUpdateRequest().data(newSpansMetricUpdateData().attributes(newSpansMetricUpdateAttributes().compute(newSpansMetricUpdateCompute().includePercentiles(false)).filter(newSpansMetricFilter().query("@http.status_code:200 service:my-service-updated")).groupBy(Collections.singletonList(newSpansMetricGroupBy().path("resource_name").tagName("resource_name")))).type(SpansMetricType.SPANS_METRICS));try{SpansMetricResponseresult=apiInstance.updateSpansMetric(SPANS_METRIC_DATA_ID,body);System.out.println(result);}catch(ApiExceptione){System.err.println("Exception when calling SpansMetricsApi#updateSpansMetric");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
"""
Update a span-based metric returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.spans_metrics_apiimportSpansMetricsApifromdatadog_api_client.v2.model.spans_metric_filterimportSpansMetricFilterfromdatadog_api_client.v2.model.spans_metric_group_byimportSpansMetricGroupByfromdatadog_api_client.v2.model.spans_metric_typeimportSpansMetricTypefromdatadog_api_client.v2.model.spans_metric_update_attributesimportSpansMetricUpdateAttributesfromdatadog_api_client.v2.model.spans_metric_update_computeimportSpansMetricUpdateComputefromdatadog_api_client.v2.model.spans_metric_update_dataimportSpansMetricUpdateDatafromdatadog_api_client.v2.model.spans_metric_update_requestimportSpansMetricUpdateRequest# there is a valid "spans_metric" in the systemSPANS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY=environ["SPANS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY"]SPANS_METRIC_DATA_ID=environ["SPANS_METRIC_DATA_ID"]body=SpansMetricUpdateRequest(data=SpansMetricUpdateData(attributes=SpansMetricUpdateAttributes(compute=SpansMetricUpdateCompute(include_percentiles=False,),filter=SpansMetricFilter(query="@http.status_code:200 service:my-service-updated",),group_by=[SpansMetricGroupBy(path="resource_name",tag_name="resource_name",),],),type=SpansMetricType.SPANS_METRICS,),)configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=SpansMetricsApi(api_client)response=api_instance.update_spans_metric(metric_id=SPANS_METRIC_DATA_ID,body=body)print(response)
# Update a span-based metric returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::SpansMetricsAPI.new# there is a valid "spans_metric" in the systemSPANS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY=ENV["SPANS_METRIC_DATA_ATTRIBUTES_FILTER_QUERY"]SPANS_METRIC_DATA_ID=ENV["SPANS_METRIC_DATA_ID"]body=DatadogAPIClient::V2::SpansMetricUpdateRequest.new({data:DatadogAPIClient::V2::SpansMetricUpdateData.new({attributes:DatadogAPIClient::V2::SpansMetricUpdateAttributes.new({compute:DatadogAPIClient::V2::SpansMetricUpdateCompute.new({include_percentiles:false,}),filter:DatadogAPIClient::V2::SpansMetricFilter.new({query:"@http.status_code:200 service:my-service-updated",}),group_by:[DatadogAPIClient::V2::SpansMetricGroupBy.new({path:"resource_name",tag_name:"resource_name",}),],}),type:DatadogAPIClient::V2::SpansMetricType::SPANS_METRICS,}),})papi_instance.update_spans_metric(SPANS_METRIC_DATA_ID,body)
/**
* Update a span-based metric returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.SpansMetricsApi(configuration);// there is a valid "spans_metric" in the system
constSPANS_METRIC_DATA_ID=process.env.SPANS_METRIC_DATA_IDasstring;constparams: v2.SpansMetricsApiUpdateSpansMetricRequest={body:{data:{attributes:{compute:{includePercentiles: false,},filter:{query:"@http.status_code:200 service:my-service-updated",},groupBy:[{path:"resource_name",tagName:"resource_name",},],},type:"spans_metrics",},},metricId: SPANS_METRIC_DATA_ID,};apiInstance.updateSpansMetric(params).then((data: v2.SpansMetricResponse)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
"""
Delete a span-based metric returns "OK" response
"""fromosimportenvironfromdatadog_api_clientimportApiClient,Configurationfromdatadog_api_client.v2.api.spans_metrics_apiimportSpansMetricsApi# there is a valid "spans_metric" in the systemSPANS_METRIC_DATA_ID=environ["SPANS_METRIC_DATA_ID"]configuration=Configuration()withApiClient(configuration)asapi_client:api_instance=SpansMetricsApi(api_client)api_instance.delete_spans_metric(metric_id=SPANS_METRIC_DATA_ID,)
# Delete a span-based metric returns "OK" responserequire"datadog_api_client"api_instance=DatadogAPIClient::V2::SpansMetricsAPI.new# there is a valid "spans_metric" in the systemSPANS_METRIC_DATA_ID=ENV["SPANS_METRIC_DATA_ID"]api_instance.delete_spans_metric(SPANS_METRIC_DATA_ID)
// Delete a span-based metric returns "OK" response
packagemainimport("context""fmt""os""github.com/DataDog/datadog-api-client-go/v2/api/datadog""github.com/DataDog/datadog-api-client-go/v2/api/datadogV2")funcmain(){// there is a valid "spans_metric" in the system
SpansMetricDataID:=os.Getenv("SPANS_METRIC_DATA_ID")ctx:=datadog.NewDefaultContext(context.Background())configuration:=datadog.NewConfiguration()apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewSpansMetricsApi(apiClient)r,err:=api.DeleteSpansMetric(ctx,SpansMetricDataID)iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `SpansMetricsApi.DeleteSpansMetric`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}}
// Delete a span-based metric returns "OK" responseimportcom.datadog.api.client.ApiClient;importcom.datadog.api.client.ApiException;importcom.datadog.api.client.v2.api.SpansMetricsApi;publicclassExample{publicstaticvoidmain(String[]args){ApiClientdefaultClient=ApiClient.getDefaultApiClient();SpansMetricsApiapiInstance=newSpansMetricsApi(defaultClient);// there is a valid "spans_metric" in the systemStringSPANS_METRIC_DATA_ID=System.getenv("SPANS_METRIC_DATA_ID");try{apiInstance.deleteSpansMetric(SPANS_METRIC_DATA_ID);}catch(ApiExceptione){System.err.println("Exception when calling SpansMetricsApi#deleteSpansMetric");System.err.println("Status code: "+e.getCode());System.err.println("Reason: "+e.getResponseBody());System.err.println("Response headers: "+e.getResponseHeaders());e.printStackTrace();}}}
/**
* Delete a span-based metric returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration();constapiInstance=newv2.SpansMetricsApi(configuration);// there is a valid "spans_metric" in the system
constSPANS_METRIC_DATA_ID=process.env.SPANS_METRIC_DATA_IDasstring;constparams: v2.SpansMetricsApiDeleteSpansMetricRequest={metricId: SPANS_METRIC_DATA_ID,};apiInstance.deleteSpansMetric(params).then((data: any)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));