nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: awslabs/aws-embedded-metrics-node
Pull request #24 (2020-03-02 14:34:20)

Set MAX_DIMENSIONS=9
The backend will fail to parse entries with more than 9 dimensions.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.



Patch:
diff --git a/src/Constants.ts b/src/Constants.ts
index 0de30c8..2838abc 100644
--- a/src/Constants.ts
+++ b/src/Constants.ts
@@ -14,6 +14,6 @@
  */
 
 export enum Constants {
-  MAX_DIMENSIONS = 10,
+  MAX_DIMENSIONS = 9,
   DEFAULT_NAMESPACE = 'aws-embedded-metrics',
 }


Test patch:
diff --git a/src/serializers/__tests__/LogSerializer.test.ts b/src/serializers/__tests__/LogSerializer.test.ts
index e2e3ecb..8bd216a 100644
--- a/src/serializers/__tests__/LogSerializer.test.ts
+++ b/src/serializers/__tests__/LogSerializer.test.ts
@@ -21,11 +21,11 @@ test('serializes dimensions', () => {
   assertJsonEquality(resultJson, expected);
 });
 
-test('cannot serialize more than 10 dimensions', () => {
+test('cannot serialize more than 9 dimensions', () => {
   // arrange
   const dimensions: any = {};
   const dimensionPointers = [];
-  const allowedDimensions = 10;
+  const allowedDimensions = 9;
   const dimensionsToAdd = 11;
   for (let i = 0; i < dimensionsToAdd; i++) {
     const expectedKey = `${i}`;
Repository: awslabs/aws-embedded-metrics-node
Pull request #72 (2020-11-24 16:23:27)

Copy shouldUseDefaultDimensions to new MetricsContext
*Issue #71*

*Description of changes:*
Using shouldUseDefaultDimensions to populate new MetricsContext on copy.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.


jaredcnance: Thanks for the PR! Looks good to me. Can we have a test that verifies this behavior?
Glen-Moonpig: > Thanks for the PR! Looks good to me. Can we have a test that verifies this behavior?

I have added a new unit test.

Patch:
diff --git a/src/logger/MetricsContext.ts b/src/logger/MetricsContext.ts
index 72434d6..6dc8d4e 100644
--- a/src/logger/MetricsContext.ts
+++ b/src/logger/MetricsContext.ts
@@ -57,7 +57,8 @@ export class MetricsContext {
     properties?: IProperties,
     dimensions?: Array<Record<string, string>>,
     defaultDimensions?: Record<string, string>,
-    timestamp?: Date | number,
+    shouldUseDefaultDimensions?: boolean,
+    timestamp?: Date | number
   ) {
     this.namespace = namespace || Configuration.namespace
     this.properties = properties || {};
@@ -65,6 +66,9 @@ export class MetricsContext {
     this.timestamp = timestamp;
     this.meta.Timestamp = MetricsContext.resolveMetaTimestamp(timestamp);
     this.defaultDimensions = defaultDimensions || {};
+    if (shouldUseDefaultDimensions != undefined) {
+      this.shouldUseDefaultDimensions = shouldUseDefaultDimensions
+    }
   }
 
   private static resolveMetaTimestamp(timestamp?: Date | number): number {
@@ -191,6 +195,7 @@ export class MetricsContext {
       Object.assign({}, this.properties),
       Object.assign([], this.dimensions),
       this.defaultDimensions,
+      this.shouldUseDefaultDimensions,
       this.timestamp
     );
   }


Test patch:
diff --git a/src/logger/__tests__/MetricsContext.test.ts b/src/logger/__tests__/MetricsContext.test.ts
index 3d7a8c8..ee9d4f6 100644
--- a/src/logger/__tests__/MetricsContext.test.ts
+++ b/src/logger/__tests__/MetricsContext.test.ts
@@ -189,3 +189,17 @@ test('createCopyWithContext copies properties and dimensions', () => {
   expect(newContext).not.toBe(context);
   expect(newContext).toStrictEqual(context);
 });
+
+test('createCopyWithContext copies shouldUseDefaultDimensions', () => {
+  // arrange
+  const context = MetricsContext.empty();
+  context.setDimensions([]);
+  context.setDefaultDimensions({ Key: 'Value' });
+
+  // act
+  const newContext = context.createCopyWithContext();
+
+  // assert
+  expect(newContext).not.toBe(context);
+  expect(newContext.getDimensions()).toEqual([])
+});