Skip to content

Commit 553f2c6

Browse files
committed
Merge branch '617-jprofiler'
2 parents 70379c3 + 0d376f2 commit 553f2c6

13 files changed

Lines changed: 266 additions & 40 deletions

File tree

.idea/.rakeTasks

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dictionaries/bhale.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ The buildpack supports extension through the use of Git repository forking. The
8888
* [JaCoCo Agent](docs/framework-jacoco_agent.md) ([Configuration](docs/framework-jacoco_agent.md#configuration))
8989
* [Java Memory Assistant](docs/framework-java_memory_assistant.md) ([Configuration](docs/framework-java_memory_assistant.md#configuration))
9090
* [Java Options](docs/framework-java_opts.md) ([Configuration](docs/framework-java_opts.md#configuration))
91+
* [JProfiler Profiler](docs/framework-jprofiler_profiler.md) ([Configuration](docs/framework-jprofiler_profiler.md#configuration))
9192
* [JRebel Agent](docs/framework-jrebel_agent.md) ([Configuration](docs/framework-jrebel_agent.md#configuration))
9293
* [JMX](docs/framework-jmx.md) ([Configuration](docs/framework-jmx.md#configuration))
9394
* [Luna Security Provider](docs/framework-luna_security_provider.md) ([Configuration](docs/framework-luna_security_provider.md#configuration))

config/components.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ frameworks:
5656
- "JavaBuildpack::Framework::JacocoAgent"
5757
- "JavaBuildpack::Framework::JavaMemoryAssistant"
5858
- "JavaBuildpack::Framework::Jmx"
59+
- "JavaBuildpack::Framework::JprofilerProfiler"
5960
- "JavaBuildpack::Framework::JrebelAgent"
6061
- "JavaBuildpack::Framework::LunaSecurityProvider"
6162
- "JavaBuildpack::Framework::MariaDbJDBC"

config/jprofiler_profiler.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Cloud Foundry Java Buildpack
2+
# Copyright 2013-2018 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# JMX configuration
17+
---
18+
version: 10.+
19+
repository_root: https://download.run.pivotal.io/jprofiler
20+
enabled: false
21+
nowait: true
22+
port: 8849
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# JProfiler Profiler Framework
2+
The JProfiler Profiler Framework contributes JProfiler configuration to the application at runtime.
3+
4+
<table>
5+
<tr>
6+
<td><strong>Detection Criterion</strong></td>
7+
<td><tt>enabled</tt> set in the <tt>config/jprofiler_profiler.yml</tt> file</td>
8+
</tr>
9+
<tr>
10+
<td><strong>Tags</strong></td>
11+
<td><tt>jprofiler-profiler=&lt;version&gt;</tt></td>
12+
</tr>
13+
</table>
14+
Tags are printed to standard output by the buildpack detect script
15+
16+
## Configuration
17+
For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][].
18+
19+
The framework can be configured by creating or modifying the [`config/jprofiler_profiler.yml`][] file in the buildpack fork. The framework uses the [`Repository` utility support][repositories] and so it supports the [version syntax][] defined there.
20+
21+
| Name | Description
22+
| ---- | -----------
23+
| `enabled` | Whether to enable the JProfiler Profiler
24+
| `port` | The port that the JProfiler Profiler will listen on. Defaults to `8849`.
25+
| `nowait` | Whether to start process without waiting for JProfiler to connect first. Defaults to `true`.
26+
| `repository_root` | The URL of the JProfiler Profiler repository index ([details][repositories]).
27+
| `version` | The version of the JProfiler Profiler to use. Candidate versions can be found in [this listing][].
28+
29+
## Creating SSH Tunnel
30+
After starting an application with the JPorfiler Profiler enabled, an SSH tunnel must be created to the container. To create that SSH container, execute the following command:
31+
32+
```bash
33+
$ cf ssh -N -T -L <LOCAL_PORT>:localhost:<REMOTE_PORT> <APPLICATION_NAME>
34+
```
35+
36+
The `REMOTE_PORT` should match the `port` configuration for the application (`8849` by default). The `LOCAL_PORT` can be any open port on your computer, but typically matches the `REMOTE_PORT` where possible.
37+
38+
Once the SSH tunnel has been created, your JProfiler Profiler should connect to `localhost:<LOCAL_PORT>` for debugging.
39+
40+
![JProfiler Configuration](framework-jprofiler_profiler.png)
41+
42+
[`config/jprofiler_profiler.yml`]: ../config/jprofiler_profiler.yml
43+
[Configuration and Extension]: ../README.md#configuration-and-extension
44+
[this listing]: http://download.pivotal.io.s3.amazonaws.com/jprofiler/index.yml
45+
[repositories]: extending-repositories.md
46+
[version syntax]: extending-repositories.md#version-syntax-and-ordering
74.7 KB
Loading

docs/framework-your_kit_profiler.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# YourKit Profiler Framework
2-
The YourKit Profiler Framework contributes YourKit Profielr configuration to the application at runtime. **Note:** This framework is only useful in Diego-based containers with SSH access enabled.
2+
The YourKit Profiler Framework contributes YourKit Profiler configuration to the application at runtime.
33

44
<table>
55
<tr>

lib/java_buildpack/component/java_opts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def add_javaagent_with_props(path, props)
6060
# @param [Properties] props to append to the +agentpath+ entry
6161
# @return [JavaOpts] +self+ for chaining
6262
def add_agentpath_with_props(path, props)
63-
add_preformatted_options "-agentpath:#{qualify_path path}=" + props.map { |k, v| "#{k}=#{v}" }.join(',')
63+
add_preformatted_options "-agentpath:#{qualify_path path}=" + props.map { |k, v| v ? "#{k}=#{v}" : k }.join(',')
6464
end
6565

6666
# Adds an +agentpath+ entry to the +JAVA_OPTS+. Prepends +$PWD+ to the path (relative to the droplet root) to
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# frozen_string_literal: true
2+
3+
# Cloud Foundry Java Buildpack
4+
# Copyright 2013-2018 the original author or authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
require 'fileutils'
19+
require 'java_buildpack/component/versioned_dependency_component'
20+
require 'java_buildpack/framework'
21+
require 'java_buildpack/util/qualify_path'
22+
23+
module JavaBuildpack
24+
module Framework
25+
26+
# Encapsulates the functionality for enabling zero-touch JProfiler profiler support.
27+
class JprofilerProfiler < JavaBuildpack::Component::VersionedDependencyComponent
28+
include JavaBuildpack::Util
29+
30+
def initialize(context, &version_validator)
31+
super(context, &version_validator)
32+
@component_name = 'JProfiler Profiler'
33+
end
34+
35+
# (see JavaBuildpack::Component::BaseComponent#compile)
36+
def compile
37+
download_tar
38+
end
39+
40+
# (see JavaBuildpack::Component::BaseComponent#release)
41+
def release
42+
properties = { 'port' => port }
43+
properties['nowait'] = nil if nowait
44+
45+
@droplet
46+
.java_opts
47+
.add_agentpath_with_props(file_name, properties)
48+
end
49+
50+
protected
51+
52+
# (see JavaBuildpack::Component::VersionedDependencyComponent#supports?)
53+
def supports?
54+
@configuration['enabled']
55+
end
56+
57+
private
58+
59+
def file_name
60+
@droplet.sandbox + 'bin/linux-x64/libjprofilerti.so'
61+
end
62+
63+
def nowait
64+
v = @configuration['nowait']
65+
v.nil? ? true : v
66+
end
67+
68+
def port
69+
@configuration['port'] || 8_849
70+
end
71+
72+
end
73+
74+
end
75+
end

0 commit comments

Comments
 (0)