|
15 | 15 | static char* create_metrics(nr_segment_t* segment,
|
16 | 16 | nrtime_t duration,
|
17 | 17 | const char* product,
|
| 18 | + nr_datastore_t type, |
18 | 19 | const char* collection,
|
19 | 20 | const char* operation,
|
20 | 21 | nr_segment_datastore_t* datastore,
|
@@ -59,12 +60,23 @@ static char* create_metrics(nr_segment_t* segment,
|
59 | 60 | }
|
60 | 61 |
|
61 | 62 | if (txn->options.database_name_reporting_enabled) {
|
62 |
| - nr_datastore_instance_set_database_name(&datastore->instance, |
63 |
| - instance->database_name); |
| 63 | + /* |
| 64 | + * According the agent-specs Datastore-Metrics-PORTED.md: |
| 65 | + * There are datastores that do not have the notion of a database name and |
| 66 | + * they are exempt from collecting it. The following list recognizes |
| 67 | + * datastores for which a database name is not applicable. DynamoDb is one |
| 68 | + * such case and as such the db.instance attribute should not be set. |
| 69 | + */ |
| 70 | + |
| 71 | + if (NR_DATASTORE_DYNAMODB != type) { |
| 72 | + nr_datastore_instance_set_database_name(&datastore->instance, |
| 73 | + instance->database_name); |
| 74 | + } |
64 | 75 | }
|
65 | 76 |
|
66 | 77 | instance_metric = nr_formatf("Datastore/instance/%s/%s/%s", product,
|
67 | 78 | instance->host, instance->port_path_or_id);
|
| 79 | + |
68 | 80 | nr_segment_add_metric(segment, instance_metric, false);
|
69 | 81 | nr_datastore_instance_set_host(&datastore->instance, instance->host);
|
70 | 82 | nr_datastore_instance_set_port_path_or_id(&datastore->instance,
|
@@ -208,9 +220,9 @@ bool nr_segment_datastore_end(nr_segment_t** segment_ptr,
|
208 | 220 | * The allWeb and allOther rollup metrics are created at the end of the
|
209 | 221 | * transaction since the background status may change.
|
210 | 222 | */
|
211 |
| - scoped_metric |
212 |
| - = create_metrics(segment, duration, datastore_string, collection, |
213 |
| - operation, &datastore, params->instance); |
| 223 | + scoped_metric = create_metrics(segment, duration, datastore_string, |
| 224 | + params->datastore.type, collection, operation, |
| 225 | + &datastore, params->instance); |
214 | 226 |
|
215 | 227 | nr_segment_set_name(segment, scoped_metric);
|
216 | 228 |
|
@@ -256,8 +268,8 @@ bool nr_segment_datastore_end(nr_segment_t** segment_ptr,
|
256 | 268 | break;
|
257 | 269 | }
|
258 | 270 | }
|
259 |
| - |
260 | 271 | datastore.component = nr_strdup(datastore_string);
|
| 272 | + datastore.db_system = params->db_system; |
261 | 273 |
|
262 | 274 | if (input_query) {
|
263 | 275 | nrobj_t* obj = nro_new_hash();
|
|
0 commit comments