Skip to content

Commit

Permalink
Truncate long strings by default to comply to NR validation
Browse files Browse the repository at this point in the history
  • Loading branch information
DKarim committed Jul 10, 2024
1 parent 46424e4 commit db4044c
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 8 deletions.
6 changes: 6 additions & 0 deletions docs/guide/src/docs/asciidoc/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ WARNING: If you use the library in a non-Micronaut environment (e.g., Grails), e
The events can optionally implement the `NewRelicInsightsEvent` interface,
which let you fine-tune the `eventType` and `timestamp` properties.

All event values are truncated to comply to the NewRelic Insights API limits:

* 255 characters when agent is used
* 4096 characters when using the API directly. +
https://docs.newrelic.com/docs/data-apis/custom-data/custom-events/data-requirements-limits-custom-event-data/#general

You can have getters annotated with `@Flatten` to include them in the event.
Those getters should return a `Map<String, Object>`.
Then all the entries in the map will be included in the event.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2022-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.agorapulse.micronaut.newrelic.limitation;

import com.agorapulse.micronaut.newrelic.AsyncNewRelicInsightsService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2022-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.agorapulse.micronaut.newrelic.limitation;

import com.agorapulse.micronaut.newrelic.DefaultNewRelicInsightsService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2022-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.agorapulse.micronaut.newrelic.limitation;

import com.agorapulse.micronaut.newrelic.DefaultNewRelicInsightsService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2022-2024 Agorapulse.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.agorapulse.micronaut.newrelic.limitation;

public interface NewRelicLimitationsService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
*/
package com.agorapulse.micronaut.newrelic

import com.agorapulse.micronaut.newrelic.limitation.NewRelicLimitationsService
import io.micronaut.test.annotation.MockBean

import io.micronaut.test.extensions.spock.annotation.MicronautTest
import jakarta.inject.Inject
import spock.lang.Specification
Expand All @@ -28,12 +27,6 @@ class BeanIntrospectionEventPayloadExtractorSpec extends Specification {

@Inject
BeanIntrospectionEventPayloadExtractor extractor
//
// @MockBean(NewRelicLimitationsService)
// NewRelicLimitationsService newRelicLimitationsService = Mock(NewRelicLimitationsService) {
// getMaxValueLength() >> TEST_MAX_VALUE_LENGTH
// truncateValue()
// }

void 'extract payload from event with Flatten'() {
given:
Expand Down

0 comments on commit db4044c

Please sign in to comment.