Skip to content

Commit

Permalink
Merge pull request #1 from crshanks/crshanks-add-obfuscation
Browse files Browse the repository at this point in the history
Add obfuscation example and sharedflow
  • Loading branch information
crshanks authored Oct 11, 2024
2 parents 96fb645 + 1764968 commit 6a75865
Show file tree
Hide file tree
Showing 22 changed files with 527 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<APIProxy revision="1" name="newrelic-trace-and-metric-and-log-obfuscate">
<DisplayName/>
<Description/>
<Policies/>
<ProxyEndpoints>
<ProxyEndpoint>default</ProxyEndpoint>
</ProxyEndpoints>
<Resources/>
<TargetEndpoints>
<TargetEndpoint>backend</TargetEndpoint>
</TargetEndpoints>
</APIProxy>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlowCallout continueOnError="true" enabled="true" name="FC-NRInstrumentationObfuscate">
<DisplayName>FC-NRInstrumentationObfuscate</DisplayName>
<Parameters/>
<SharedFlowBundle>nr-instrumentation-obfuscate-sharedflow</SharedFlowBundle>
</FlowCallout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlowCallout continueOnError="true" enabled="true" name="FC-NRLogAPI">
<DisplayName>FC-NRLogAPI</DisplayName>
<Parameters/>
<SharedFlowBundle>nr-log-api-sharedflow</SharedFlowBundle>
</FlowCallout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlowCallout continueOnError="true" enabled="true" name="FC-NRMetricAPI">
<DisplayName>FC-NRMetricAPI</DisplayName>
<Parameters/>
<SharedFlowBundle>nr-metric-api-sharedflow</SharedFlowBundle>
</FlowCallout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<FlowCallout continueOnError="true" enabled="true" name="FC-NRTraceAPI">
<DisplayName>FC-NRTraceAPI</DisplayName>
<Parameters/>
<SharedFlowBundle>nr-trace-api-sharedflow</SharedFlowBundle>
</FlowCallout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint name="default">
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<Flows/>
<PostFlow name="PostFlow">
<Request/>
<Response>
<Step>
<Name>FC-NRInstrumentationObfuscate</Name>
</Step>
</Response>
</PostFlow>
<PostClientFlow name="PostClientFlow">
<Response>
<Step>
<Name>FC-NRTraceAPI</Name>
</Step>
<Step>
<Name>FC-NRMetricAPI</Name>
</Step>
<Step>
<Name>FC-NRLogAPI</Name>
</Step>
</Response>
</PostClientFlow>
<HTTPProxyConnection>
<BasePath>/swapi/trace-and-metric-and-log-obfuscate</BasePath>
</HTTPProxyConnection>
<RouteRule name="backend">
<TargetEndpoint>backend</TargetEndpoint>
</RouteRule>
</ProxyEndpoint>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<TargetEndpoint name="backend">
<HTTPTargetConnection>
<URL>replaced_by_config_json</URL>
</HTTPTargetConnection>
</TargetEndpoint>
30 changes: 30 additions & 0 deletions examples/newrelic-trace-and-metric-and-log-obfuscate/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"configurations": [
{
"name": "test",
"policies": [],
"proxies": [
{
"name": "default.xml",
"tokens": [
{
"xpath": "/ProxyEndpoint/HTTPProxyConnection/BasePath",
"value": "/newrelic/trace-and-metric-and-log-obfuscate"
}
]
}
],
"targets": [
{
"name": "backend.xml",
"tokens": [
{
"xpath": "/TargetEndpoint/HTTPTargetConnection/URL",
"value": "https://swapi.dev/api/people/1/?format=json"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
ORG=${APIGEE_ORG:-"default here if not set as an env variable"}
ENV=${APIGEE_ENV:-"default here if not set as an env variable"}

mvn clean install -Ptest -Dorg=$ORG -Denv=$ENV -Dbearer=$(gcloud auth print-access-token)
24 changes: 24 additions & 0 deletions examples/newrelic-trace-and-metric-and-log-obfuscate/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Copyright (C) 2014 Apigee Corporation 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 http://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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent-pom</artifactId>
<groupId>com.newrelic.apigee</groupId>
<version>1.0</version>
<relativePath>../shared-pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.newrelic.apigee</groupId>
<artifactId>newrelic-trace-and-metric-and-log-obfuscate</artifactId>
<version>1.0</version>
<name>newrelic-trace-and-metric-and-log-obfuscate</name>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"configurations": [
{
"name": "test",
"policies": [
{
"name": "JS-NRInstrumentationObfuscate.xml",
"tokens": [
{
"xpath": "/Javascript/Properties/Property[@name='tracesSampler']",
"value": "parentbased_always_on"
},
{
"xpath": "/Javascript/Properties/Property[@name='tracesSamplerArg']",
"value": 1.0
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
ORG=${APIGEE_ORG:-"default here if not set as an env variable"}
ENV=${APIGEE_ENV:-"default here if not set as an env variable"}

mvn clean install -Ptest -Dorg=$ORG -Denv=$ENV -Dbearer=$(gcloud auth print-access-token)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
Copyright (C) 2014 Apigee Corporation
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
http://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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>parent-pom</artifactId>
<groupId>com.newrelic.apigee</groupId>
<version>1.0</version>
<relativePath>../parent-sharedflow-pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<groupId>com.newrelic.apigee</groupId>
<artifactId>nr-instrumentation-obfuscate-sharedflow</artifactId>
<version>1.0</version>
<name>nr-instrumentation-obfuscate-sharedflow</name>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<SharedFlowBundle revision="1" name="nr-instrumentation-obfuscate-sharedflow">
<DisplayName>nr-instrumentation-obfuscate-sharedflow</DisplayName>
<Description>Shared flow to prepare New Relic Trace API distributed tracing and Metric API metrics</Description>
<Policies>
<Policy>JS-NRInstrumentationObfuscate</Policy>
</Policies>
<Resources>
<Resource>jsc://JS-NRInstrumentationObfuscate.js</Resource>
</Resources>
<SharedFlows>
<SharedFlow>default</SharedFlow>
</SharedFlows>
</SharedFlowBundle>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Javascript async="false" continueOnError="true" enabled="true" timeLimit="200" name="JS-NRInstrumentationObfuscate">
<DisplayName>JS-NRInstrumentationObfuscate</DisplayName>
<Properties>
<!--
Tracer sampler configuration:
- always_on - Sampler that always samples spans, regardless of the parent span’s sampling decision.
- always_off - Sampler that never samples spans, regardless of the parent span’s sampling decision.
- traceidratio - Sampler that samples probabalistically based on rate.
- parentbased_always_on - (default) Sampler that respects its parent span’s sampling decision, but otherwise always samples.
- parentbased_always_off - Sampler that respects its parent span’s sampling decision, but otherwise never samples.
- parentbased_traceidratio - Sampler that respects its parent span’s sampling decision, but otherwise samples probabalistically based on rate.
-->
<Property name='tracesSampler'>replaced_by_config_json</Property>
<!--
Sampling probability can be set with tracesSamplerArg if the sampler is traceidratio or parentbased_traceidratio.
Rate must be in the range [0.0,1.0]. When not provided rate will be set to 1.0 (maximum rate possible).
-->
<Property name='tracesSamplerArg'>replaced_by_config_json</Property>
</Properties>
<ResourceURL>jsc://NRInstrumentationObfuscate.js</ResourceURL>
</Javascript>
Loading

0 comments on commit 6a75865

Please sign in to comment.